feat(rollup): create entry point without css
This commit is contained in:
+19
-4
@@ -1,3 +1,4 @@
|
||||
import path from 'path';
|
||||
import resolve from '@rollup/plugin-node-resolve';
|
||||
import commonjs from '@rollup/plugin-commonjs';
|
||||
import babel from '@rollup/plugin-babel';
|
||||
@@ -12,7 +13,7 @@ import pkg from './package.json';
|
||||
const isProd = process.env.NODE_ENV === 'production';
|
||||
const processEnv = isProd ? 'production' : 'development';
|
||||
|
||||
export default {
|
||||
const baseConfig = ({ mainFile = pkg.main, moduleFile = pkg.module, extractCss = false } = {}) => ({
|
||||
input: 'src/index.ts',
|
||||
external: ['react', 'react-dom', /@babel\/runtime/],
|
||||
onwarn(warning, rollupWarn) {
|
||||
@@ -22,13 +23,13 @@ export default {
|
||||
},
|
||||
output: [
|
||||
{
|
||||
file: pkg.main,
|
||||
file: mainFile,
|
||||
format: 'cjs',
|
||||
sourcemap: true,
|
||||
exports: 'named',
|
||||
},
|
||||
{
|
||||
file: pkg.module,
|
||||
file: moduleFile,
|
||||
format: 'esm',
|
||||
sourcemap: true,
|
||||
exports: 'named',
|
||||
@@ -38,10 +39,13 @@ export default {
|
||||
replace({
|
||||
__ENV__: JSON.stringify(processEnv),
|
||||
__REACT_FLOW_VERSION__: JSON.stringify(pkg.version),
|
||||
// this comes from the easy-peasy dependency 'memoizerific'
|
||||
'process.env.FORCE_SIMILAR_INSTEAD_OF_MAP': JSON.stringify('true'),
|
||||
}),
|
||||
bundleSize(),
|
||||
postcss({
|
||||
minimize: isProd,
|
||||
extract: extractCss,
|
||||
}),
|
||||
babel({
|
||||
exclude: 'node_modules/**',
|
||||
@@ -56,4 +60,15 @@ export default {
|
||||
include: 'node_modules/**',
|
||||
}),
|
||||
],
|
||||
};
|
||||
});
|
||||
|
||||
export default isProd
|
||||
? [
|
||||
baseConfig(),
|
||||
baseConfig({
|
||||
mainFile: 'dist/nocss/ReactFlow-nocss.js',
|
||||
moduleFile: 'dist/nocss/ReactFlow-nocss.esm.js',
|
||||
extractCss: path.resolve('dist/nocss/style.css'),
|
||||
}),
|
||||
]
|
||||
: baseConfig();
|
||||
|
||||
Reference in New Issue
Block a user