-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
rollup.config.js
58 lines (54 loc) · 1.63 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
import { terser } from "rollup-plugin-terser";
import babel from "@rollup/plugin-babel";
import fs from "fs";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import replace from "@rollup/plugin-replace";
const packageJson = JSON.parse(fs.readFileSync("./package.json"));
export default [
createConfig("esm"),
createConfig("system"),
createConfig("umd"),
createConfig("umd", true),
createConfig("esm", true),
];
function createConfig(format, server = false) {
const babelOpts = server
? { babelHelpers: "bundled", envName: "server" }
: { babelHelpers: "bundled" };
return {
input: `./src/single-spa-layout${server ? "-server" : ""}.js`,
output: {
format,
file: `dist/${format}/single-spa-layout${server ? "-server" : ""}.min.${
format === "umd" ? "c" : ""
}js`,
name: format === "umd" ? "singleSpaLayout" : null,
banner: `/* single-spa-layout@${packageJson.version} - ${format} */`,
globals: {
"single-spa": "singleSpa",
},
},
external: ["single-spa", "path", "fs", "stream", /^parse5.*/, "merge2"],
plugins: [
nodeResolve(),
commonjs(),
babel(babelOpts),
replace({
"process.env.BABEL_ENV": JSON.stringify("production"),
preventAssignment: true,
}),
process.env.DEVELOPMENT !== "true" &&
terser({
compress: {
passes: 2,
},
output: {
comments(node, comment) {
return comment.value.trim().startsWith("single-spa-layout@");
},
},
}),
],
};
}