-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesbuild.js
35 lines (30 loc) · 876 Bytes
/
esbuild.js
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
const esbuild = require('esbuild')
const vuePlugin = require('esbuild-plugin-vue3')
const aliasPlugin = require('esbuild-plugin-alias')
// "build": "esbuild app/javascript/*.* --bundle --sourcemap --format=esm --outdir=app/assets/builds --public-path=/assets",
const CONFIG = {
entryPoints: ['app/javascript/*.*'],
format: 'esm',
plugins: [
aliasPlugin({
vue: require.resolve(`vue/dist/${process.env.NODE_ENV === 'production' ? 'vue.esm-browser.prod.js' : 'vue.esm-browser.js'}`)
}),
vuePlugin()
],
bundle: true,
sourcemap: true,
publicPath: '/assets',
outdir: 'app/assets/builds',
logOverride: {
'commonjs-variable-in-esm': 'silent'
}
}
async function main () {
if (process.argv.includes('--watch')) {
const ctx = await esbuild.context(CONFIG)
await ctx.watch()
} else {
await esbuild.build(CONFIG)
}
}
main()