27 lines
751 B
JavaScript
27 lines
751 B
JavaScript
import { build, context } from 'esbuild';
|
|
import { readFileSync } from 'fs';
|
|
import { join } from 'path';
|
|
|
|
const watch = process.argv.includes('--watch');
|
|
|
|
const common = {
|
|
bundle: true,
|
|
sourcemap: false,
|
|
logLevel: 'info',
|
|
alias: { 'vue': 'vue/dist/vue.esm-bundler.js' },
|
|
};
|
|
|
|
const entries = [
|
|
{ entryPoints: ['src/main/index.ts'], outfile: 'dist/main.js', platform: 'node', format: 'cjs', external: [] },
|
|
{ entryPoints: ['src/panels/default/index.ts'], outfile: 'dist/panels/default.js', platform: 'browser', format: 'iife', external: [] },
|
|
];
|
|
|
|
if (watch) {
|
|
for (const e of entries) {
|
|
const ctx = await context({ ...common, ...e });
|
|
await ctx.watch();
|
|
}
|
|
} else {
|
|
for (const e of entries) await build({ ...common, ...e });
|
|
}
|