browser-image-resizer/build.js

29 lines
639 B
JavaScript
Raw Permalink Normal View History

2024-10-18 08:52:45 +00:00
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...');
}
})();