Skip to content

Commit a04ef27

Browse files
build: replace webpack with rollup in order to optimize bundle
Save devDependencies: * [email protected] * [email protected] * [email protected] * [email protected] Remove `webpack.config.js` and add `rollup.config.js` Update npm scripts `build:min` and `build:unmin`
1 parent 474c8cd commit a04ef27

File tree

3 files changed

+29
-31
lines changed

3 files changed

+29
-31
lines changed

package.json

+7-5
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"scripts": {
88
"benchmark": "node benchmark",
99
"build": "npm run clean && npm run build:min && npm run build:unmin",
10-
"build:min": "cross-env NODE_ENV=production webpack --output-filename html-react-parser.min.js",
11-
"build:unmin": "cross-env NODE_ENV=development webpack --output-filename html-react-parser.js",
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",
1212
"clean": "rimraf dist",
1313
"coveralls": "nyc report --reporter=text-lcov | coveralls",
1414
"lint": "eslint --ignore-path .gitignore .",
@@ -58,9 +58,11 @@
5858
"react": "^16",
5959
"react-dom": "^16",
6060
"rimraf": "^2.6.3",
61-
"standard-version": "^6.0.1",
62-
"webpack": "^4.35.0",
63-
"webpack-cli": "^3.3.5"
61+
"rollup": "^1.16.2",
62+
"rollup-plugin-commonjs": "^10.0.0",
63+
"rollup-plugin-node-resolve": "^5.0.4",
64+
"rollup-plugin-uglify": "^6.0.2",
65+
"standard-version": "^6.0.1"
6466
},
6567
"peerDependencies": {
6668
"react": "^0.14 || ^15 || ^16"

rollup.config.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import commonjs from 'rollup-plugin-commonjs';
2+
import resolve from 'rollup-plugin-node-resolve';
3+
import { uglify } from 'rollup-plugin-uglify';
4+
5+
const config = {
6+
external: ['react'],
7+
input: 'index.js',
8+
output: {
9+
format: 'umd',
10+
globals: {
11+
react: 'React'
12+
},
13+
name: 'HTMLReactParser'
14+
},
15+
plugins: [commonjs(), resolve({ browser: true })]
16+
};
17+
18+
if (process.env.NODE_ENV === 'production') {
19+
config.plugins.push(uglify());
20+
}
21+
22+
export default config;

webpack.config.js

-26
This file was deleted.

0 commit comments

Comments
 (0)