// const esbuild = require("esbuild"); import * as esbuild from "esbuild"; import {sassPlugin} from "esbuild-sass-plugin"; const args = process.argv.slice(2); const watch = args.includes("--watch"); const deploy = args.includes("--deploy"); const loader = { ".svg": "file", ".eot": "file", ".ttf": "file", ".woff": "file", ".otf": "file", }; const plugins = [ sassPlugin(), ]; 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(); }); }