-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
90 lines (84 loc) · 2.5 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
80
81
82
83
84
85
86
87
88
89
90
import postcssCssnext from "postcss-cssnext";
import commonjs from "rollup-plugin-commonjs";
import resolve from "rollup-plugin-node-resolve";
import postcss from "rollup-plugin-postcss";
import replace from "rollup-plugin-replace";
import typescript from "rollup-plugin-typescript";
// import filesize from "rollup-plugin-filesize";
// import visualizer from "rollup-plugin-visualizer";
const breakpoints = {
sm: "(min-width: 576px)",
md: "(min-width: 768px)",
lg: "(min-width: 1312px)",
};
// This will likely be needed in the future to support icons.
// const svgPath = () => ({
// name: "svgPath",
// load(id) {
// if (extname(id) !== ".svg") {
// return null;
// }
// const data = readFileSync(id, "utf-8");
// return new Promise((resolve, reject) =>
// parseString(data, (err, result) => {
// if (err) {
// return reject(err);
// }
// const path = result.svg.path[0].$.d;
// const code = `export default '${path}';`;
// return resolve({code});
// })
// );
// },
// });
export default {
input: "src/index.tsx",
output: [
{
file: "dist/unifier.js",
format: "cjs",
name: "unified",
exports: "named",
globals: {
react: "React",
"prop-types": "PropTypes",
classnames: "classnames",
"classnames/bind": "classnames",
"react-dom": "ReactDOM",
},
sourcemap: "inline",
},
],
external: ["react", "prop-types", "classnames/bind", "classnames", "react-dom"],
plugins: [
typescript({lib: ["es5", "es6", "dom", "esnext", "dom.iterable"], target: "es5"}),
commonjs(),
resolve(),
postcss({
sourceMap: true,
writeDefinitions: true,
// Put the CSS directly into the exported file. We might change this in the future for client
// side performance.
extract: false,
plugins: [
// Add custom media breakpoints so we can do things like "display: flex, smDisplay: none"
// to hide an item on small displays.
postcssCssnext({
features: {
customMedia: {
extensions: breakpoints,
},
},
}),
],
}),
replace({
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || "development"),
}),
// This will likely be needed in the future to support icons.
// svgPath(),
// These are useful for debugging why the bundle is so big, but not needed for dev.
// visualizer(),
// filesize(),
],
};