Skip to content

Commit 5dd4f07

Browse files
build(package): refactor webpack config and generate sourcemap
1 parent fa66dfc commit 5dd4f07

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

package.json

+2-2
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 -o dist/html-react-parser.min.js",
11-
"build:unmin": "cross-env NODE_ENV=development webpack -o dist/html-react-parser.js",
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",
1212
"clean": "rimraf dist",
1313
"coveralls": "nyc report --reporter=text-lcov | coveralls",
1414
"lint": "eslint --ignore-path .gitignore .",

webpack.config.js

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
var path = require('path');
1+
const { resolve } = require('path');
2+
const { NODE_ENV } = process.env;
23

3-
/**
4-
* Webpack configuration.
5-
*/
6-
module.exports = {
7-
entry: path.resolve(__dirname, 'index.js'),
4+
const config = {
5+
entry: resolve(__dirname, 'index.js'),
86
output: {
97
library: 'HTMLReactParser',
10-
libraryTarget: 'umd'
8+
libraryTarget: 'umd',
9+
path: resolve(__dirname, 'dist')
1110
},
1211
externals: {
1312
react: {
@@ -17,5 +16,11 @@ module.exports = {
1716
root: 'React'
1817
}
1918
},
20-
mode: process.env.NODE_ENV
19+
mode: NODE_ENV
2120
};
21+
22+
if (NODE_ENV === 'production') {
23+
config.devtool = 'source-map';
24+
}
25+
26+
module.exports = config;

0 commit comments

Comments
 (0)