43 lines
827 B
JavaScript
43 lines
827 B
JavaScript
const esbuild = require("esbuild");
|
|
const {sassPlugin} = require('esbuild-sass-plugin');
|
|
|
|
const ESBUILD_CONFIG = {
|
|
entryPoints: [
|
|
'./src/index.js',
|
|
'./src/index.scss'
|
|
],
|
|
bundle: true,
|
|
outdir: "./dist",
|
|
plugins: [
|
|
sassPlugin({
|
|
embedded: true
|
|
}),
|
|
],
|
|
logLevel: 'info',
|
|
sourcemap: "external",
|
|
minify: true,
|
|
entryNames: "[dir]/[ext]/[name]"
|
|
};
|
|
|
|
async function build() {
|
|
await esbuild.build(ESBUILD_CONFIG)
|
|
}
|
|
|
|
async function watch() {
|
|
const context = await esbuild.context(ESBUILD_CONFIG)
|
|
|
|
await context.watch();
|
|
|
|
}
|
|
|
|
switch (process.argv[2]) {
|
|
case "build":
|
|
build();
|
|
break;
|
|
case "watch":
|
|
watch();
|
|
break;
|
|
default:
|
|
console.error(`Unknown command: ${process.argv[2]}`);
|
|
process.exit(1)
|
|
}
|