-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathrollup.worker.config.mjs
53 lines (50 loc) · 1.31 KB
/
rollup.worker.config.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// inspired by https://justinribeiro.com/chronicle/2020/07/17/building-module-web-workers-for-cross-browser-compatibility-with-rollup/
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
import typescript from '@rollup/plugin-typescript';
import { defineConfig } from 'rollup';
const config = defineConfig([
{
input: ['./src/index.ts'],
treeshake: 'smallest',
output: {
dir: './build/esm',
format: 'esm',
},
external: ['./worker'],
plugins: [
typescript({ tsconfig: './tsconfig.json', inlineSourceMap: false, sourceMap: false, inlineSources: false }),
terser({
mangle: {
module: true,
},
}),
],
},
{
input: ['./src/_worker.ts'],
output: {
file: './build/esm/worker.ts',
format: 'esm',
},
treeshake: 'smallest',
plugins: [
commonjs(),
typescript({ tsconfig: './tsconfig.json', inlineSourceMap: false, sourceMap: false, inlineSources: false }),
resolve(),
terser({
mangle: {
module: true,
},
}),
{
name: 'worker-to-string',
renderChunk(code) {
return `export default \`${code}\`;`;
},
},
],
},
]);
export default config;