TL; DR . Use webpack define plugin to set process.env.NODE_ENV to production.
Long version:
React, Redux, and many other JS libraries include additional checks and error logging that simplify development. However, you obviously do not want this in production, as they make your code base larger and slower. These checks are usually wrapped in expressions that look like this:
if (process.env.NODE_ENV !== 'production') { // do development checks }
The error you are getting is Redux telling you that although you minimized the code, process.env.NODE_ENV not set to production , so development checks still exist. To fix this, you will want to use the webpack define plugin to set process.env.NODE_ENV in production.
var webpack = require('webpack'); module.exports = { entry: [ './src/index.js' ], output: { path: __dirname, publicPath: '/', filename: 'bundle.js' }, module: { loaders: [{ exclude: /node_modules/, loader: 'babel', query: { presets: ['react', 'es2015', 'stage-1'] } }] }, resolve: { extensions: ['', '.js', '.jsx'] }, devServer: { historyApiFallback: true, contentBase: './' }, plugins: [ new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV) }), ] };
Note that I am defining the value of process.env.NODE_ENV for what it configured for you when running webpack. Therefore, to generate your production package, you need to run NODE_ENV=production webpack -p , not just webpack -p . This will replace any instance of process.env.NODE_ENV with production in your kit. Thus, the check that I showed above will now look like this:
if ('production' !== 'production') { // do development checks }
Minifiers are smart enough to detect that the code in the if statement will never happen and remove it from your production package. Thus, you get the best of both worlds: the best development experience and the lack of additional code in your production team :)