From d8eecc3421fc045659c7578c12eb0b86714d84c2 Mon Sep 17 00:00:00 2001 From: inhji Date: Mon, 20 Mar 2023 11:20:40 +0100 Subject: [PATCH] =?UTF-8?q?=E2=80=9Eassets/build.js=E2=80=9C=20hinzuf?= =?UTF-8?q?=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/build.js | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 assets/build.js diff --git a/assets/build.js b/assets/build.js new file mode 100644 index 0000000..fc884e9 --- /dev/null +++ b/assets/build.js @@ -0,0 +1,50 @@ +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' } +} + +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, + watch, + sourcemap: 'inline' + } +} + +if (deploy) { + opts = { + ...opts, + minify: true + } +} + +const promise = esbuild.build(opts) + +if (watch) { + promise.then(_result => { + process.stdin.on('close', () => { + process.exit(0) + }) + + process.stdin.resume() + }) +} \ No newline at end of file