When I run ‘wepack -p’, there’re many warnings. WARNING in bundle.js from UglifyJs

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]
Dropping side-effect-free statement [./
/react-router/lib/deprecateObjectPropert
ies.js:65,0]
Side effects in initialization of unused variable _ret [.//react-router/lib/dep
recateObjectProperties.js:63,0]
Condition always true [./
/react/lib/findDOMNode.js:46,0]
Condition always true [.//react/lib/instantiateReactComponent.js:80,0]
Dropping unreachable code [./
/react/lib/shouldUpdateReactComponent.js:40,0]
Condition always true [.//react/lib/traverseAllChildren.js:158,0]
Condition always true [./
/react-router/lib/Redirect.js:97,0]
Side effects in initialization of unused variable _reactRouter [./modules/App.js
:2,0]
Condition always true [.//react-router/lib/IndexRedirect.js:58,0]
Condition always true [./
/react-router/lib/IndexRoute.js:55,0]
Condition always true [.//react-router/lib/Route.js:50,0]
Dropping side-effect-free statement [./
/react-router/lib/getComponents.js:49,0]

Side effects in initialization of unused variable _ret2 [.//react-router/lib/ge
tComponents.js:47,0]
Condition always true [./
/react-router//history/lib/createMemoryHistory.js:67,
0]
Condition always true [./
/react/lib/ReactDOMComponent.js:907,0]
Dropping side-effect-free statement [.//react/lib/ReactEventListener.js:72,0]
Dropping unused function handleTopLevelWithPath [./
/react/lib/ReactEventListene
r.js:98,0]
Dropping unused variable DOCUMENT_FRAGMENT_NODE_TYPE [./~/react/lib/ReactEventLi
stener.js:26,0]

Author: Fantashit

2 thoughts on “When I run ‘wepack -p’, there’re many warnings. WARNING in bundle.js from UglifyJs

  1. Don’t worry about it – it’s just uglify letting you know that it has stripped out unreachable code.

  2. @laixstx But after the package bundle file is too large, how do you usually make it smaller size?

    • Do not include entries like 'webpack-dev-server/client?http://127.0.0.1:8080/' to the production build.
    • Skip 'react-hot' for the production build.
    • Use a production supported way of generating sourcemaps. See the devtool documentation for further details. The one you chose includes the sourcemaps to the generated bundle growing its size substantially.

    It’s probably better to open questions like this to Stack Overflow. You’ll get faster answers through it. 👍

Comments are closed.