2023-03-20 11:20:40 +01:00
|
|
|
const esbuild = require('esbuild')
|
|
|
|
|
|
|
|
const args = process.argv.slice(2)
|
|
|
|
const watch = args.includes('--watch')
|
|
|
|
const deploy = args.includes('--deploy')
|
|
|
|
|
|
|
|
const loader = {
|
|
|
|
// Add loaders for images/fonts/etc, e.g. { '.svg': 'file' }
|
2023-03-21 07:19:10 +01:00
|
|
|
'.js': 'jsx'
|
2023-03-20 11:20:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const plugins = [
|
|
|
|
// Add and configure plugins here
|
|
|
|
]
|
|
|
|
|
|
|
|
let opts = {
|
2023-09-09 13:49:08 +02:00
|
|
|
entryPoints: [
|
|
|
|
'js/app.js',
|
|
|
|
'js/public.js'
|
|
|
|
],
|
2023-03-20 11:20:40 +01:00
|
|
|
bundle: true,
|
2023-09-09 13:06:27 +02:00
|
|
|
target: 'es2016',
|
2023-03-20 11:20:40 +01:00
|
|
|
outdir: '../priv/static/assets',
|
2023-09-09 14:09:28 +02:00
|
|
|
external: ["*.css", "fonts/*", "images/*"],
|
2023-03-20 11:20:40 +01:00
|
|
|
logLevel: 'info',
|
|
|
|
loader,
|
|
|
|
plugins
|
|
|
|
}
|
|
|
|
|
|
|
|
if (watch) {
|
|
|
|
opts = {
|
|
|
|
...opts,
|
|
|
|
sourcemap: 'inline'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (deploy) {
|
|
|
|
opts = {
|
|
|
|
...opts,
|
|
|
|
minify: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const promise = esbuild.build(opts)
|
|
|
|
|
2023-03-21 07:19:10 +01:00
|
|
|
if (watch) {
|
|
|
|
esbuild.context(opts).then(ctx => ctx.watch())
|
2023-07-19 20:45:45 +02:00
|
|
|
}
|