I have tried options such as Uglifyjs,babelli (babel-minify ).nothing seems to be working.Uglify throws some error like this:
Name expected [au680.bundle.js:147541,22]>
Following is my webpack configurations file. I am using webpack 2.3.1 with dynamic routing of react-router. Hope it helps you.
var path = require('path');
var webpack = require('webpack');
var package=require('./package.json');
var config = require('./config');
var ManifestPlugin = require('webpack-manifest-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
var getPlugins = function(){
var pluginsList = [
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: Infinity,
filename: 'vendor.bundle_[hash].js'
}),
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify("production")
}
}),
new webpack.NamedModulesPlugin(),
new ManifestPlugin({
fileName: 'build-manifest.json'
})
];
pluginsList.push(new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false
}));
pluginsList.push(new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
},
output: {
comments: false
},
sourceMap: false,
minimize: true
}));
return pluginsList;
}
module.exports = {
cache: true,
output: {
path:path.join(__dirname, "dist/js"),
filename: "[name]_[hash].js",
chunkFilename:"[name]_[hash].js",
publicPath:config.envConfig.JS_ASSETS_PATH
},
devServer: {
contentBase: path.join(__dirname, "dist"),
compress: true,
port: 8080
},
entry: {
index: [
package.paths.app
],
vendor: [
'react', 'react-dom','phrontend',
'react-ga'
]
},
plugins: getPlugins(),
target: 'web',
module: {
rules: [
{
test: /.jsx?$/,
exclude: /node_modules/,
use: [{
loader: 'babel-loader',
}]
}
]
},
};