forked from patternfly/patternfly-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.base.js
56 lines (53 loc) · 1.45 KB
/
rollup.base.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
const resolve = require('@rollup/plugin-node-resolve');
const commonjs = require('@rollup/plugin-commonjs');
const scss = require('rollup-plugin-scss');
const replace = require('@rollup/plugin-replace');
const { terser } = require('rollup-plugin-terser');
const isProduction = process.env.IS_PRODUCTION;
let exitCode = 0;
function circularFailPlugin() {
return {
name: 'circluarFailPlugin',
buildEnd() {
if (exitCode !== 0) {
process.exit(exitCode);
}
}
};
}
module.exports = ({ packageName, name }) => ({
input: 'dist/esm/index.js',
output: {
file: `dist/umd/${packageName}${isProduction ? '.min' : ''}.js`,
format: 'umd',
name,
globals: {
react: 'React',
'react-dom': 'ReactDOM'
}
},
external: ['react', 'react-dom'],
plugins: [
replace({
'process.env.NODE_ENV': `'${isProduction ? 'production' : 'development'}'`
}),
resolve(),
commonjs(),
scss(),
isProduction && terser(),
circularFailPlugin()
],
onwarn(warning) {
if (warning.code === 'CIRCULAR_DEPENDENCY') {
const split = warning.message.split(':');
if (warning.message.includes('d3-interpolate')) {
// eslint-disable-next-line no-console
console.error(`\x1b[33m(!) ${split[0]}:\x1b[0m${split[1]}`);
} else {
// eslint-disable-next-line no-console
console.error(`\x1b[31m(!) ${split[0]}:\x1b[0m${split[1]}`);
exitCode = 1;
}
}
}
});