My webpack.config.js:
var webpack = require('webpack');
var path = require('path');
module.exports = {
devtool: 'inline-source-map',
entry: [
'webpack-dev-server/client?http://127.0.0.1:8080/',
'webpack/hot/only-dev-server',
'./app'
],
output: {
path: path.join(__dirname, 'build'),
filename:'bundle.js'
},
resolve: {
modulesDirectories: ['node_modules', 'app'],
extensions: ['','.js']
},
module:{
loaders: [
{
test:/\.jsx?$/,
exclude:/node_modules/,
loaders:[
'react-hot','babel?presets[]=react,presets[]=es2015'
]
}
]
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new webpack.optimize.UglifyJsPlugin()
]
};
And when I run ‘wepack -p’, there’re many warnings:
WARNING in bundle.js from UglifyJs
Condition always true [.//react/lib/ReactMount.js:764,0]/react-router/lib/deprecateObjectPropert
Dropping side-effect-free statement [./
ies.js:65,0]
Side effects in initialization of unused variable _ret [.//react-router/lib/dep/react/lib/findDOMNode.js:46,0]
recateObjectProperties.js:63,0]
Condition always true [./
Condition always true [.//react/lib/instantiateReactComponent.js:80,0]/react/lib/shouldUpdateReactComponent.js:40,0]
Dropping unreachable code [./
Condition always true [.//react/lib/traverseAllChildren.js:158,0]/react-router/lib/Redirect.js:97,0]
Condition always true [./
Side effects in initialization of unused variable _reactRouter [./modules/App.js
:2,0]
Condition always true [.//react-router/lib/IndexRedirect.js:58,0]/react-router/lib/IndexRoute.js:55,0]
Condition always true [./
Condition always true [.//react-router/lib/Route.js:50,0]/react-router/lib/getComponents.js:49,0]
Dropping side-effect-free statement [./Side effects in initialization of unused variable _ret2 [./
/react-router/lib/ge/react-router/
tComponents.js:47,0]
Condition always true [.//history/lib/createMemoryHistory.js:67,/react/lib/ReactDOMComponent.js:907,0]
0]
Condition always true [./
Dropping side-effect-free statement [.//react/lib/ReactEventListener.js:72,0]/react/lib/ReactEventListene
Dropping unused function handleTopLevelWithPath [./
r.js:98,0]
Dropping unused variable DOCUMENT_FRAGMENT_NODE_TYPE [./~/react/lib/ReactEventLi
stener.js:26,0]
Don’t worry about it – it’s just uglify letting you know that it has stripped out unreachable code.
@laixstx But after the package bundle file is too large, how do you usually make it smaller size?
'webpack-dev-server/client?http://127.0.0.1:8080/'
to the production build.'react-hot'
for the production build.It’s probably better to open questions like this to Stack Overflow. You’ll get faster answers through it.👍