Skip to content

Commit

Permalink
feat(rollup): create entry point without css
Browse files Browse the repository at this point in the history
  • Loading branch information
moklick committed Jan 18, 2021
1 parent 11f385c commit 6dd25d5
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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) {
Expand All @@ -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',
Expand All @@ -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/**',
Expand All @@ -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();

0 comments on commit 6dd25d5

Please sign in to comment.