-
Notifications
You must be signed in to change notification settings - Fork 4
/
rollup.config.js
79 lines (77 loc) · 2.66 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
// @format
import { terser } from "rollup-plugin-terser";
import resolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import babel from "rollup-plugin-babel";
import replace from "rollup-plugin-replace";
import postcss from "rollup-plugin-postcss";
import url from "@rollup/plugin-url";
// `npm run build` -> `production` is true
// `npm run dev` -> `production` is false
const production = !process.env.ROLLUP_WATCH;
module.exports = [
{
input: "src/js/main.js",
output: {
dir: "public",
format: "cjs",
sourcemap: !production
},
plugins: [
url({
// by default, rollup-plugin-url will not handle font files
include: ["**/*.woff", "**/*.woff2", "**/*.png"],
// setting infinite limit will ensure that the files
// are always bundled with the code, not copied to /dist
limit: Infinity
}),
postcss({
extensions: [".css"],
// NOTE: We don't inject css styles, as that would mess with styles coming
// from styled-components
inject: false
}),
replace({
"process.env.NODE_ENV": JSON.stringify("production")
}),
babel({
exclude: "node_modules/**"
}),
// NOTE: `main: false` allows npm link'ed packages to be resolved too.
resolve({ main: false, module: true, browser: true }),
// NOTE: styled-components won't compile without this configuration of
// commonjs: https://github.com/styled-components/styled-components/issues/1654#issuecomment-441151140
commonjs({
include: "node_modules/**",
// left-hand side can be an absolute path, a path
// relative to the current directory, or the name
// of a module in node_modules
namedExports: {
"node_modules/react/index.js": [
"cloneElement",
"createContext",
"Component",
"createElement"
],
"node_modules/react-dom/index.js": ["render", "hydrate"],
"node_modules/react-is/index.js": [
"isElement",
"isValidElementType",
"ForwardRef"
],
"node_modules/automation-events/build/es5/bundle.js": [
"AutomationEventList",
"createCancelAndHoldAutomationEvent",
"createCancelScheduledValuesAutomationEvent",
"createExponentialRampToValueAutomationEvent",
"createLinearRampToValueAutomationEvent",
"createSetTargetAutomationEvent",
"createSetValueAutomationEvent",
"createSetValueCurveAutomationEvent"
]
}
}),
production && terser()
]
}
];