-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrollup.config.js
96 lines (93 loc) · 2.82 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
91
92
93
94
95
96
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import babel from "@rollup/plugin-babel";
import postcss from "rollup-plugin-postcss";
import peerDepsExternal from "rollup-plugin-peer-deps-external";
import alias from "@rollup/plugin-alias";
import { visualizer } from "rollup-plugin-visualizer";
import pkg from "./package.json";
const path = require("path");
const customResolver = resolve({
extensions: [".mjs", ".js", ".jsx", ".json", ".sass", ".scss"],
});
const projectRootDir = path.resolve(__dirname);
const warningSuppressionFilter = /imported from external module 'react'/;
export default {
input: "src/index.js",
output: [
{
name: "mainsail-ui",
sourcemap: true,
file: pkg.main,
format: "cjs",
},
/**
* Note: This is a future facing output
* May not be necessary at the moment
*/
{
sourcemap: true,
file: pkg.module,
format: "es",
},
],
plugins: [
peerDepsExternal(),
postcss({
use: ["sass"],
config: {
path: "./postcss.config.js",
},
minimize: true,
inject: {
insertAt: "bottom",
},
}),
babel({ exclude: "node_modules/**", babelHelpers: "bundled" }),
alias({
entries: [
{
find: "utility",
replacement: path.resolve(projectRootDir, "src/utility"),
customResolver,
},
{
find: "components",
replacement: path.resolve(projectRootDir, "src/components"),
customResolver,
},
{
find: "styles",
replacement: path.resolve(projectRootDir, "src/styles"),
customResolver,
},
],
}),
resolve(),
commonjs(),
process.env.NODE_ENV !== "production" &&
visualizer({
filename: "bundle-viz.html",
open: false,
projectRoot: "/src",
}),
],
/*
*
* This specific warning suppression pattern exists because
* some 3rd-party deps import unused modules.
*
* Rollup is smart enough to not include them, but
* the warning provided will fail the build since we
* run with a strict --failAfterWarnings
*
* If future dependencies provide more issues, we can re-evaluate
*/
onwarn: function (message) {
const str = message.toString();
if (warningSuppressionFilter.test(str)) {
return;
}
console.error(message);
},
};