-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.mjs
48 lines (46 loc) · 1.4 KB
/
build.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import * as esbuild from 'esbuild'
import pkg from 'esbuild-plugin-external-global';
const { externalGlobalPlugin } = pkg;
let ctx = await esbuild.context({
entryPoints: ['./src/index.jsx'],
outfile: './dist/plugin.js',
bundle: true,
format: 'esm',
external: [
'react',
'react/jsx-runtime',
'react-dom',
'antd',
'@ant-design/pro-components',
'react-query',
'@veramo-community/veramo-react',
'@veramo-community/agent-explorer-plugin',
'react-router-dom',
'uuid',
'date-fns',
'antd/lib/button',
],
plugins: [
externalGlobalPlugin({
'react': 'window.React',
'react/jsx-runtime': 'window.reactjsxruntime',
'react-dom': 'window.ReactDOM',
'antd': 'window.antd',
'@ant-design/pro-components': 'window.antdPro',
'react-query': 'window.reactquery',
'@veramo-community/veramo-react': 'window.veramoreact',
'@veramo-community/agent-explorer-plugin': 'window.agentexplorerplugin',
'react-router-dom': 'window.reactrouterdom',
'uuid': 'window.uuid',
'date-fns': 'window.datefns',
'antd/lib/button': 'window.antlibbutton',
})
]
})
if (process.argv.includes('--serve')) {
await ctx.watch()
let { port } = await ctx.serve({ servedir: './dist', port: 8080 })
console.log(`Plugin available at http://localhost:${port}/plugin.js`)
} else {
await ctx.rebuild().finally(() => process.exit(0))
}