Skip to content

Commit 8315832

Browse files
build(webpack): upgrade to webpack v4 and add build script
devDependencies: * webpack@4.19.0 * webpack-cli@3.1.0
1 parent 5f0e991 commit 8315832

File tree

2 files changed

+14
-22
lines changed

2 files changed

+14
-22
lines changed

package.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,20 @@
55
"author": "Mark <mark@remarkablemark.org>",
66
"main": "index.js",
77
"scripts": {
8-
"build:unmin": "NODE_ENV=development webpack index.js dist/html-react-parser.js",
9-
"build:min": "NODE_ENV=production webpack -p index.js dist/html-react-parser.min.js",
8+
"build": "npm run clean && npm run build:min && npm run build:unmin",
9+
"build:min": "NODE_ENV=production webpack -o dist/html-react-parser.min.js",
10+
"build:unmin": "NODE_ENV=development webpack -o dist/html-react-parser.js",
1011
"clean": "rm -rf dist",
1112
"commitmsg": "commitlint -e $GIT_PARAMS",
1213
"cover": "istanbul cover _mocha -- -R spec \"test/**/*\"",
1314
"coveralls": "cat coverage/lcov.info | coveralls",
1415
"lint": "eslint --ignore-path .gitignore .",
1516
"lint:fix": "npm run lint -- --fix",
1617
"precommit": "lint-staged",
17-
"prepublishOnly": "npm run clean && npm run build:unmin && npm run build:min",
18+
"prepublishOnly": "npm run build",
1819
"release": "standard-version --no-verify",
1920
"test": "mocha",
20-
"test:benchmark": "node ./test/benchmark.js"
21+
"test:benchmark": "node test/benchmark.js"
2122
},
2223
"repository": {
2324
"type": "git",
@@ -53,7 +54,8 @@
5354
"react": "^16",
5455
"react-dom": "^16",
5556
"standard-version": "^4.3.0",
56-
"webpack": "^3.11.0"
57+
"webpack": "^4.19.0",
58+
"webpack-cli": "^3.1.0"
5759
},
5860
"peerDependencies": {
5961
"react": "^0.14 || ^15 || ^16"

webpack.config.js

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,21 @@
1-
'use strict';
1+
var path = require('path');
22

33
/**
4-
* Module dependencies.
5-
*/
6-
var webpack = require('webpack');
7-
8-
/**
9-
* Export webpack configuration.
4+
* Webpack configuration.
105
*/
116
module.exports = {
7+
entry: path.resolve(__dirname, 'index.js'),
128
output: {
139
library: 'HTMLReactParser',
1410
libraryTarget: 'umd'
1511
},
1612
externals: {
1713
react: {
18-
root: 'React',
19-
commonjs2: 'react',
14+
amd: 'react',
2015
commonjs: 'react',
21-
amd: 'react'
16+
commonjs2: 'react',
17+
root: 'React'
2218
}
2319
},
24-
plugins: [
25-
new webpack.optimize.ModuleConcatenationPlugin(),
26-
new webpack.optimize.OccurrenceOrderPlugin(),
27-
new webpack.DefinePlugin({
28-
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
29-
})
30-
]
20+
mode: process.env.NODE_ENV
3121
};

0 commit comments

Comments
 (0)