-
-
Notifications
You must be signed in to change notification settings - Fork 269
/
Copy pathrollup.config.mjs
91 lines (85 loc) · 2.01 KB
/
rollup.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
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
80
81
82
83
84
85
86
87
88
89
90
91
import babel from "@rollup/plugin-babel";
import resolve from "@rollup/plugin-node-resolve";
import rust from "@wasm-tool/rollup-plugin-rust";
import commonjs from '@rollup/plugin-commonjs';
import terser from "@rollup/plugin-terser";
const esmPlugins = [
babel({
exclude: "node_modules/**",
babelHelpers: "runtime",
presets: ["solid", "@babel/preset-env"],
plugins: [['@babel/transform-runtime']]
}),
rust({ inlineWasm: true, wasmOptArgs: ["-O4"] }),
resolve({ extensions: [".js", ".jsx"] })
];
const cjsPlugins = [
resolve(),
commonjs()
];
export default [
// 1. Build the raw ESM modules
{
input: ["src/index.js", "src/ui.js", "src/worker.js"],
output: [
{
dir: "dist",
format: "es"
}
],
external: [/@babel\/runtime/],
plugins: esmPlugins
},
// 2. Build the main (combined) standalone IIFE from the ESM output
{
input: "dist/index.js",
output: [
{
file: "dist/bundle/asciinema-player.js",
format: "iife",
name: "AsciinemaPlayer"
},
{
file: "dist/bundle/asciinema-player.min.js",
format: "iife",
name: "AsciinemaPlayer",
plugins: [terser()]
}
],
plugins: cjsPlugins
},
// 3. Build the UI-only standalone IIFE from the ESM output
{
input: "dist/ui.js",
output: [
{
file: "dist/bundle/asciinema-player-ui.js",
format: "iife",
name: "AsciinemaPlayer"
},
{
file: "dist/bundle/asciinema-player-ui.min.js",
format: "iife",
name: "AsciinemaPlayer",
plugins: [terser()]
}
],
plugins: cjsPlugins
},
// 4. Build the worker-only standalone IIFE from the ESM output
{
input: "dist/worker.js",
output: [
{
file: "dist/bundle/asciinema-player-worker.js",
format: "iife"
},
{
file: "dist/bundle/asciinema-player-worker.min.js",
format: "iife",
plugins: [terser()]
}
],
plugins: cjsPlugins
}
];