Skip to content

Commit 55b2b4e

Browse files
build(rollup): upgrade rollup, consolidate config, remove cross-env
rollup ^1.26.3 → ^1.32.1 Consolidate `build:min` and `build:unmin` into 1 `build` script. Remove `cross-env` since NODE_ENV is no longer needed to distinguish between builds. In `rollup.config.js`, export both configs for minified and unminified bundles. Generate sourcemap for both builds (previously, sourcemap was only generated for unmin or development bundle).
1 parent b2dc83b commit 55b2b4e

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

package.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
"main": "index.js",
77
"scripts": {
88
"benchmark": "node benchmark",
9-
"build": "npm run clean && npm run build:min && npm run build:unmin",
10-
"build:min": "cross-env NODE_ENV=production rollup --config --file dist/html-react-parser.min.js --sourcemap",
11-
"build:unmin": "cross-env NODE_ENV=development rollup --config --file dist/html-react-parser.js",
9+
"build": "rollup --config",
1210
"clean": "rimraf dist",
1311
"lint": "eslint --ignore-path .gitignore --ignore-pattern /examples/ .",
1412
"lint:dts": "dtslint .",
1513
"lint:fix": "npm run lint -- --fix",
16-
"prepublishOnly": "npm run lint && npm run lint:dts && npm test && npm run build",
14+
"prepublishOnly": "npm run lint && npm run lint:dts && npm test && npm run clean && npm run build",
1715
"release": "standard-version --no-verify",
1816
"test": "mocha",
1917
"test:coverage": "nyc npm test",
@@ -44,7 +42,6 @@
4442
"@commitlint/config-conventional": "^8.3.4",
4543
"@types/react": "^16.9.35",
4644
"benchmark": "^2.1.4",
47-
"cross-env": "^7.0.2",
4845
"dtslint": "^3.6.4",
4946
"eslint": "^7.1.0",
5047
"eslint-plugin-prettier": "^3.1.3",
@@ -57,7 +54,7 @@
5754
"react": "^16",
5855
"react-dom": "^16",
5956
"rimraf": "^3.0.2",
60-
"rollup": "^1.26.3",
57+
"rollup": "^1.32.1",
6158
"rollup-plugin-commonjs": "^10.1.0",
6259
"rollup-plugin-node-resolve": "^5.2.0",
6360
"rollup-plugin-uglify": "^6.0.4",

rollup.config.js

+13-9
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,25 @@ import commonjs from 'rollup-plugin-commonjs';
22
import resolve from 'rollup-plugin-node-resolve';
33
import { uglify } from 'rollup-plugin-uglify';
44

5-
const config = {
5+
/**
6+
* Build rollup config for development (default) or production (minify = true).
7+
*
8+
* @param {Boolean} [minify=false]
9+
* @return {Object}
10+
*/
11+
const getConfig = (minify = false) => ({
612
external: ['react'],
713
input: 'index.js',
814
output: {
15+
file: `dist/html-react-parser${minify ? '.min' : ''}.js`,
916
format: 'umd',
1017
globals: {
1118
react: 'React'
1219
},
13-
name: 'HTMLReactParser'
20+
name: 'HTMLReactParser',
21+
sourcemap: true
1422
},
15-
plugins: [commonjs(), resolve({ browser: true })]
16-
};
23+
plugins: [commonjs(), resolve({ browser: true }), minify && uglify()]
24+
});
1725

18-
if (process.env.NODE_ENV === 'production') {
19-
config.plugins.push(uglify());
20-
}
21-
22-
export default config;
26+
export default [getConfig(), getConfig(true)];

0 commit comments

Comments
 (0)