-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildWorker.js
46 lines (43 loc) · 905 Bytes
/
buildWorker.js
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
import { build } from 'vite';
import path from 'path';
import { fileURLToPath } from 'url';
import { minify } from 'terser';
import terser from '@rollup/plugin-terser';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
async function buildWorker() {
let name = 'worker';
let outDir = 'src/lib/bundled';
await build({
configFile: false,
build: {
outDir,
lib: {
entry: path.resolve(__dirname, `./src/lib/${name}.js`),
fileName: name,
name
},
emptyOutDir: false,
minify: true,
sourcemap: false,
rollupOptions: {
output: [
{
sourcemap: false,
format: 'es',
dir: outDir,
manualChunks: false,
inlineDynamicImports: true,
name: 'app',
compact: true,
plugins: [terser()]
}
],
plugins: [terser()]
}
}
});
console.log('Worker built.');
}
(async () => {
await buildWorker();
})();