-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.mjs
More file actions
53 lines (47 loc) · 1.43 KB
/
Copy pathbuild.mjs
File metadata and controls
53 lines (47 loc) · 1.43 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import * as esbuild from 'esbuild';
import { mkdirSync } from 'fs';
const watch = process.argv.includes('--watch');
const entries = [
{ in: 'src/background/service_worker.js', out: 'extension/background/service_worker.js' },
{ in: 'src/popup/popup.js', out: 'extension/popup/popup.js' },
{ in: 'src/permissions_ui/confirm.js', out: 'extension/permissions_ui/confirm.js' },
{ in: 'src/settings/settings.js', out: 'extension/settings/settings.js' },
{ in: 'src/sidepanel/sidepanel.js', out: 'extension/sidepanel/sidepanel.js' },
];
mkdirSync('extension/background', { recursive: true });
mkdirSync('extension/popup', { recursive: true });
mkdirSync('extension/permissions_ui', { recursive: true });
mkdirSync('extension/settings', { recursive: true });
mkdirSync('extension/sidepanel', { recursive: true });
const common = {
bundle: true,
format: 'esm',
platform: 'browser',
target: ['chrome109'],
logLevel: 'info',
};
async function buildAll() {
await Promise.all(
entries.map(({ in: entry, out }) =>
esbuild.build({
...common,
entryPoints: [entry],
outfile: out,
})
)
);
console.log('Build complete.');
}
if (watch) {
await Promise.all(
entries.map(({ in: entry, out }) =>
esbuild.context({ ...common, entryPoints: [entry], outfile: out }).then((ctx) => {
ctx.watch();
return ctx;
})
)
);
console.log('Watching...');
} else {
await buildAll();
}