/
rollup.config.js
72 lines (68 loc) · 1.76 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
import typescript from "rollup-plugin-typescript2";
import { terser } from "rollup-plugin-terser";
import replace from "@rollup/plugin-replace";
const tsOpts = { useTsconfigDeclarationDir: true };
const terserOpts = {
compress: {
keep_infinity: true,
pure_getters: true,
passes: 10,
},
ecma: 9,
toplevel: true,
warnings: true,
mangle: {
properties: {
regex: "^_",
},
},
nameCache: {
props: {
cname: 6,
props: {
// Component
$_hooks: "_h",
$_performUpdate: "_u",
$_flushEffects: "_f",
$_attr: "_a",
$_observeAttr: "_o",
$_dispatch: "_d",
$_adoptStyle: "_s",
$_context: "_c",
// hooks
$_values: "_v",
$_deps: "_d",
$_effects: "_e",
$_layoutEffects: "_l",
$_cleanup: "_c",
},
},
},
};
const bundle = (moduleName, format, env, external = []) => {
const isProducton = env === "production";
const ext = format === "es" ? "mjs" : "js";
return {
input: `./src/${moduleName}/index.ts`,
output: {
file: `${moduleName}/${moduleName}.${env}.${ext}`,
format,
plugins: [isProducton && terser(terserOpts)].filter(Boolean),
},
plugins: [
typescript(tsOpts),
replace({ "process.env.BUILD_ENV": JSON.stringify(env) }),
].filter(Boolean),
external,
};
};
export default [
bundle("fuco", "es", "production"),
bundle("fuco", "es", "development"),
bundle("fuco", "cjs", "production", ["../html"]),
bundle("fuco", "cjs", "development", ["../html"]),
bundle("html", "cjs", "production"),
bundle("html", "cjs", "development"),
bundle("server", "cjs", "production", ["../html", "../fuco"]),
bundle("server", "cjs", "development", ["../html", "../fuco"]),
];