-
-
Notifications
You must be signed in to change notification settings - Fork 106
/
Copy pathwatch.mjs
31 lines (28 loc) · 924 Bytes
/
watch.mjs
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
import * as esbuild from 'esbuild';
async function watch() {
const ctx = await esbuild.context({
entryPoints: [
'src/service_worker/service_worker.ts', // Main service worker entry point
'src/popup/popup.tsx' // Popup script (JSX or JS)
],
bundle: true,
sourcemap: true, // Generate source maps for easier debugging
target: 'chrome88', // Set browser target version
outdir: 'dist', // Output directory
plugins: [{
name: 'rebuild-notify',
setup(build) {
build.onEnd(result => {
console.log(`build ended with ${result.errors.length} errors`);
// HERE: somehow restart the server from here, e.g., by sending a signal that you trap and react to inside the server.
})
},
}],
define: {
'process.env.VERSION': '"' + process.env.npm_package_version + '"'
}
});
await ctx.watch(); // Watch mode
console.log('Watching for changes...');
}
watch();