Skip to content

Commit

Permalink
build: replace webpack with rollup in order to optimize bundle
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
remarkablemark committed Jul 9, 2019
1 parent 474c8cd commit a04ef27
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 31 deletions.
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"scripts": {
"benchmark": "node benchmark",
"build": "npm run clean && npm run build:min && npm run build:unmin",
"build:min": "cross-env NODE_ENV=production webpack --output-filename html-react-parser.min.js",
"build:unmin": "cross-env NODE_ENV=development webpack --output-filename html-react-parser.js",
"build:min": "cross-env NODE_ENV=production rollup --config --file dist/html-react-parser.min.js --sourcemap",
"build:unmin": "cross-env NODE_ENV=development rollup --config --file dist/html-react-parser.js",
"clean": "rimraf dist",
"coveralls": "nyc report --reporter=text-lcov | coveralls",
"lint": "eslint --ignore-path .gitignore .",
Expand Down Expand Up @@ -58,9 +58,11 @@
"react": "^16",
"react-dom": "^16",
"rimraf": "^2.6.3",
"standard-version": "^6.0.1",
"webpack": "^4.35.0",
"webpack-cli": "^3.3.5"
"rollup": "^1.16.2",
"rollup-plugin-commonjs": "^10.0.0",
"rollup-plugin-node-resolve": "^5.0.4",
"rollup-plugin-uglify": "^6.0.2",
"standard-version": "^6.0.1"
},
"peerDependencies": {
"react": "^0.14 || ^15 || ^16"
Expand Down
22 changes: 22 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import commonjs from 'rollup-plugin-commonjs';
import resolve from 'rollup-plugin-node-resolve';
import { uglify } from 'rollup-plugin-uglify';

const config = {
external: ['react'],
input: 'index.js',
output: {
format: 'umd',
globals: {
react: 'React'
},
name: 'HTMLReactParser'
},
plugins: [commonjs(), resolve({ browser: true })]
};

if (process.env.NODE_ENV === 'production') {
config.plugins.push(uglify());
}

export default config;
26 changes: 0 additions & 26 deletions webpack.config.js

This file was deleted.

0 comments on commit a04ef27

Please sign in to comment.