-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
84 lines (80 loc) · 2.68 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
import { nodeResolve as nodeResolvePlugin } from "@rollup/plugin-node-resolve";
import { babel as babelPlugin } from "@rollup/plugin-babel";
import commonjsPlugin from "@rollup/plugin-commonjs";
import postcssPlugin from "rollup-plugin-postcss";
import clearPlugin from "rollup-plugin-clear";
import jsonPlugin from "@rollup/plugin-json";
import { terser as terserPlugin } from "rollup-plugin-terser";
import { visualizer as visualizerPlugin } from "rollup-plugin-visualizer";
import autoprefixer from "autoprefixer";
import url from "postcss-url";
import hash from "object-hash";
import cssnano from "cssnano";
import path from "path";
const SRC_DIR = path.resolve(__dirname, "src");
const DIST_DIR = path.resolve(__dirname, "dist");
const development = process.env.NODE_ENV === "development";
export default {
input: `${SRC_DIR}/index.js`,
output: {
dir: DIST_DIR,
format: "es",
sourcemap: true,
manualChunks: {
image_editor: ["@toast-ui/react-image-editor"],
emojis: ["emoji-mart"],
dates: ["react-dates"],
markup: ["draft-js", "draftjs-to-html", "html-to-draftjs"]
}
},
external: ["react", "react-dom", "react-router-dom"],
plugins: [
clearPlugin({
targets: [DIST_DIR]
}),
nodeResolvePlugin({
browser: true,
extensions: [".js", ".jsx"]
}),
postcssPlugin({
minimize: false,
autoModules: false,
modules: {
generateScopedName: (name, filename, css) => {
// Ignore external CSS files
if (filename.indexOf("/node_modules/") >= 0) {
return name;
}
const componentName = filename.match(/^(.*)\/(.*)(\..*)$/)[2];
return `${componentName}-${name}_${hash({
name: name,
filename: filename
}).substring(0, 3)}`;
}
},
extract: `${DIST_DIR}/styles.css`,
plugins: [
url({
url: "inline"
}),
autoprefixer,
cssnano({
preset: [
"default",
{
calc: false
}
]
})
]
}),
jsonPlugin(),
babelPlugin({
babelHelpers: "bundled",
exclude: 'node_modules/**'
}),
commonjsPlugin(),
terserPlugin(),
development && visualizerPlugin({ open: true })
]
};