refactor(bundle): create separate plugins bundle closes #15

This commit is contained in:
moklick
2019-10-08 20:53:00 +02:00
parent 956f4fb978
commit 161ab7fdfd
10 changed files with 245 additions and 40 deletions
+42 -23
View File
@@ -10,15 +10,33 @@ import svg from 'rollup-plugin-svg';
import pkg from './package.json';
const isProd = process.env.NODE_ENV === 'production';
const external = ['react', 'react-dom', 'prop-types'];
const onwarn = (warning, rollupWarn) => {
if (warning.code !== 'CIRCULAR_DEPENDENCY') {
rollupWarn(warning);
}
};
const plugins = [
bundleSize(),
postcss({
extract: isProd
}),
resolve(),
babel({
exclude: 'node_modules/**'
}),
commonjs({
include: /node_modules/
}),
svg(),
visualizer(),
isProd && terser()
];
export default [{
input: 'src/index.js',
external: ['react', 'react-dom', 'prop-types'],
onwarn(warning, rollupWarn) {
if (warning.code !== 'CIRCULAR_DEPENDENCY') {
rollupWarn(warning);
}
},
external: external,
onwarn,
output: {
name: 'ReactFlow',
file: pkg.browser,
@@ -30,20 +48,21 @@ export default [{
'prop-types': 'PropTypes'
}
},
plugins: [
bundleSize(),
postcss({
extract: isProd
}),
resolve(),
babel({
exclude: 'node_modules/**'
}),
commonjs({
include: /node_modules/
}),
svg(),
visualizer(),
isProd && terser()
]}
];
plugins
}, {
input: 'src/plugins/index.js',
external: external,
onwarn,
output: {
name: 'ReactFlow Plugins',
file: 'dist/plugins/index.js',
format: 'umd',
sourcemap: isProd,
globals: {
react: 'React',
'react-dom': 'ReactDOM',
'prop-types': 'PropTypes'
}
},
plugins
}];