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 = {
|
|
|
|
entryPoints: ['js/app.js'],
|
|
|
|
bundle: true,
|
|
|
|
target: 'es2017',
|
|
|
|
outdir: '../priv/static/assets',
|
|
|
|
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-03-20 11:20:40 +01:00
|
|
|
if (watch) {
|
|
|
|
promise.then(_result => {
|
|
|
|
process.stdin.on('close', () => {
|
|
|
|
process.exit(0)
|
|
|
|
})
|
|
|
|
|
|
|
|
process.stdin.resume()
|
|
|
|
})
|
2023-03-21 07:19:10 +01:00
|
|
|
}
|
|
|
|
*/
|