-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.mjs
More file actions
33 lines (28 loc) · 838 Bytes
/
Copy pathbuild.mjs
File metadata and controls
33 lines (28 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import * as esbuild from 'esbuild';
import { cp, mkdir, rm } from 'node:fs/promises';
const watch = process.argv.includes('--watch');
const options = {
entryPoints: [
{ in: 'src/background/index.ts', out: 'background' },
{ in: 'src/popup/main.ts', out: 'popup' },
],
outdir: 'dist',
bundle: true,
format: 'esm',
target: 'chrome120',
sourcemap: watch ? 'inline' : false,
logLevel: 'info',
};
async function copyStatic() {
await mkdir('dist', { recursive: true });
await cp('public', 'dist', { recursive: true });
}
await rm('dist', { recursive: true, force: true });
await copyStatic();
if (watch) {
const ctx = await esbuild.context(options);
await ctx.watch();
console.log('watching src/ — reload the extension from chrome://extensions after changes');
} else {
await esbuild.build(options);
}