Skip to content

Commit 6495a8e

Browse files
Optimize webpack build with NODE_ENV and plugin
Remove branches where `process.env.NODE_ENV !== "production"` especially for React.
1 parent 626d411 commit 6495a8e

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"author": "Mark <mark@remarkablemark.org>",
66
"main": "index.js",
77
"scripts": {
8-
"build": "webpack index.js dist/html-to-react.js",
9-
"build-min": "webpack -p index.js dist/html-to-react.min.js",
8+
"build": "NODE_ENV=development webpack index.js dist/html-to-react.js",
9+
"build-min": "NODE_ENV=production webpack -p index.js dist/html-to-react.min.js",
1010
"test": "mocha",
1111
"lint": "eslint index.js \"lib/**\" \"test/**\"",
1212
"cover": "istanbul cover _mocha -- -R spec \"test/**/*\"",

webpack.config.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
'use strict';
22

3+
/**
4+
* Module dependencies.
5+
*/
6+
var webpack = require('webpack');
7+
38
/**
49
* Export webpack configuration.
510
*/
@@ -15,5 +20,11 @@ module.exports = {
1520
commonjs: 'react',
1621
amd: 'react'
1722
}
18-
}
23+
},
24+
plugins: [
25+
new webpack.optimize.OccurrenceOrderPlugin(),
26+
new webpack.DefinePlugin({
27+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
28+
})
29+
]
1930
};

0 commit comments

Comments
 (0)