chiya/assets/build.js

47 lines
723 B
JavaScript
Raw Normal View History

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',
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
}