I am testing my working javascript with minifcation using webpack. It works fine unminified, but when I add the -p flag:
NODE_ENV=production ./node_modules/webpack/bin/webpack.js -p --progress --colors
I get warnings and javascript errors. It appears that he removes things that should not. I canβt understand why.
Warnings:
WARNING in client.js from UglifyJs Side effects in initialization of unused variable React [./~/fluxible/lib/Fluxible.js:12,0] Dropping unused function $$$enumerator$$makeSettledResult [./~/fluxible/~/es6-promise/dist/es6-promise.js:361,0] Side effects in initialization of unused variable $$utils$$now [./~/fluxible/~/es6-promise/dist/es6-promise.js:35,0] Side effects in initialization of unused variable $$utils$$o_create [./~/fluxible/~/es6-promise/dist/es6-promise.js:38,0] Dropping unused variable internals [./~/react-router/~/qs/lib/utils.js:6,0] Dropping side-effect-free statement [./~/fluxible/addons/provideContext.js:6,0] Side effects in initialization of unused variable Action [./~/fluxible/~/dispatchr/lib/Dispatcher.js:7,0] Dropping unused variable internals [./~/react-router/~/qs/lib/index.js:9,0]
Here is my webpack.config.js
var ExtractTextPlugin = require('extract-text-webpack-plugin'); var path = require('path'); module.exports = { entry: [ './client.js', ], output: { path: path.join(__dirname, 'assets'), filename: 'client.js', publicPath: '/assets', }, plugins: [ new ExtractTextPlugin('styles.css'), ], module: { loaders: [ { test: /\.(js|jsx)$/, exclude: /node_modules\/(?!react-router)/, loader: 'react-hot!babel-loader?stage=0' }, { test: /\.scss$/, loader: ExtractTextPlugin.extract( // activate source maps via loader query 'css?sourceMap!' + 'sass?sourceMap' ) }, // bootstrap { test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'url-loader?limit=10000&mimetype=application/font-eot', }, { test: /\.(woff)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'url-loader?limit=10000&mimetype=application/font-woff', }, { test: /\.(woff2)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'url-loader?limit=10000&mimetype=application/font-woff2', }, { test: /\.js$/, include: /node_modules\/bootstrap/, loader: 'imports?jQuery=jquery' }, ], }, };
thanks