-
Notifications
You must be signed in to change notification settings - Fork 16
/
rollup.config.js
46 lines (43 loc) · 1.11 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
import fs from "fs";
import typescript from "@rollup/plugin-typescript";
import terser from "@rollup/plugin-terser";
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
export const nodeResolve = resolve({
browser: true,
preferBuiltins: false,
});
const create = (file, format, plugins = []) => ({
input: "build/mlcontour.js",
output: {
name: "mlcontour",
file,
format,
intro: fs.readFileSync("build/bundle_prelude.js", "utf8"),
},
treeshake: false,
plugins,
});
/** @type {import('rollup').RollupOptions[]} */
export default [
{
input: ["src/index.ts", "src/worker.ts"],
output: {
dir: "dist/staging",
format: "amd",
indent: false,
chunkFileNames: "shared.js",
minifyInternalExports: true,
},
onwarn: (message) => {
console.error(message);
throw message;
},
treeshake: true,
plugins: [nodeResolve, typescript(), commonjs()],
},
create("dist/index.cjs", "cjs"),
create("dist/index.mjs", "esm"),
create("dist/index.js", "umd"),
create("dist/index.min.js", "umd", [terser()]),
];