-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
79 lines (75 loc) · 1.5 KB
/
rollup.config.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import _dts from "rollup-plugin-dts";
import _esbuild from "rollup-plugin-esbuild";
import terser from "@rollup/plugin-terser";
import commonjs from "@rollup/plugin-commonjs";
import resolve from "@rollup/plugin-node-resolve";
import replace from "@rollup/plugin-replace";
const esbuild = _esbuild?.default ?? _esbuild;
const dts = _dts?.default ?? _dts;
const name = require("./package.json").main.replace(/\.js$/, "").replace(".mjs", "");
const bundle = (config) => ({
...config,
input: ["src/index.ts"]
});
export default [
bundle({
output: [
{
file: `${name}.js`,
format: "es"
},
],
plugins: [
esbuild(),
replace({
"from 'worker'": "from './worker.js'",
delimiters: ["", ""],
preventAssignment: true,
}),
],
}),
bundle({
output: [
{
file: `${name}.full.js`,
format: 'es',
sourcemap: false
}
],
plugins: [
esbuild(),
resolve({
moduleDirectories: ['node_modules', 'src'],
}),
commonjs()
]
}),
bundle({
plugins: [dts()],
output: {
file: `${name}.d.ts`,
format: "es",
},
}),
{
input: ["src/worker.ts"],
output: [
{
file: `dist/worker.js`,
format: "es",
},
],
plugins: [
esbuild(),
resolve({
moduleDirectories: ['node_modules']
}),
terser({
warnings: true,
mangle: {
module: true,
},
}),
],
},
];