browser-image-resizer/build.js
2024-10-18 21:52:45 +13:00

29 lines
No EOL
639 B
JavaScript

const esbuild = require('esbuild');
const watch = process.argv[2]?.includes('watch');
/** @type {esbuild.BuildOptions} */
const buildOptions = {
entryPoints: [ `${__dirname}/src/index.ts` ],
bundle: true,
format: 'esm',
treeShaking: true,
minify: false,
absWorkingDir: __dirname,
outbase: `${__dirname}/src`,
outdir: `${__dirname}/dist`,
loader: {
'.ts': 'ts'
},
tsconfig: `${__dirname}/tsconfig.json`,
};
(async () => {
if (!watch) {
await esbuild.build(buildOptions);
console.log('done');
} else {
const context = await esbuild.context(buildOptions);
await context.watch();
console.log('watching...');
}
})();