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 resolve from '@rollup/plugin-node-resolve';
|
||||||
import commonjs from '@rollup/plugin-commonjs';
|
import commonjs from '@rollup/plugin-commonjs';
|
||||||
import babel from '@rollup/plugin-babel';
|
import babel from '@rollup/plugin-babel';
|
||||||
@@ -12,7 +13,7 @@ import pkg from './package.json';
|
|||||||
const isProd = process.env.NODE_ENV === 'production';
|
const isProd = process.env.NODE_ENV === 'production';
|
||||||
const processEnv = isProd ? 'production' : 'development';
|
const processEnv = isProd ? 'production' : 'development';
|
||||||
|
|
||||||
export default {
|
const baseConfig = ({ mainFile = pkg.main, moduleFile = pkg.module, extractCss = false } = {}) => ({
|
||||||
input: 'src/index.ts',
|
input: 'src/index.ts',
|
||||||
external: ['react', 'react-dom', /@babel\/runtime/],
|
external: ['react', 'react-dom', /@babel\/runtime/],
|
||||||
onwarn(warning, rollupWarn) {
|
onwarn(warning, rollupWarn) {
|
||||||
@@ -22,13 +23,13 @@ export default {
|
|||||||
},
|
},
|
||||||
output: [
|
output: [
|
||||||
{
|
{
|
||||||
file: pkg.main,
|
file: mainFile,
|
||||||
format: 'cjs',
|
format: 'cjs',
|
||||||
sourcemap: true,
|
sourcemap: true,
|
||||||
exports: 'named',
|
exports: 'named',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
file: pkg.module,
|
file: moduleFile,
|
||||||
format: 'esm',
|
format: 'esm',
|
||||||
sourcemap: true,
|
sourcemap: true,
|
||||||
exports: 'named',
|
exports: 'named',
|
||||||
@@ -38,10 +39,13 @@ export default {
|
|||||||
replace({
|
replace({
|
||||||
__ENV__: JSON.stringify(processEnv),
|
__ENV__: JSON.stringify(processEnv),
|
||||||
__REACT_FLOW_VERSION__: JSON.stringify(pkg.version),
|
__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(),
|
bundleSize(),
|
||||||
postcss({
|
postcss({
|
||||||
minimize: isProd,
|
minimize: isProd,
|
||||||
|
extract: extractCss,
|
||||||
}),
|
}),
|
||||||
babel({
|
babel({
|
||||||
exclude: 'node_modules/**',
|
exclude: 'node_modules/**',
|
||||||
@@ -56,4 +60,15 @@ export default {
|
|||||||
include: 'node_modules/**',
|
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