refactor(bundle): create separate plugins bundle closes #15
This commit is contained in:
+42
-23
@@ -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
|
||||
}];
|
||||
|
||||
Reference in New Issue
Block a user