Answer the question
In order to leave comments, you need to log in
Does the NODE_ENV variable in production need to be set to 'production' only during the build of the project, or also during its lifetime?
There is a project, it is built on a production server (Debian) using the following script in package.json: 'cross-env NODE_ENV=production webpack'. Along with this, the following construction is used in the Webpack config:
new webpack.DefinePlugin({
NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'production'),
}),
Warning: It looks like you're using a minified copy of the development build of React. When deploying React apps to production, make sure to use the production build which skips development warnings and is faster. See https://fb.me/react-minification for more details.
You are currently using minified code outside of NODE_ENV === 'production'. This means that you are running a slower development build of Redux. You can use loose-envify ( https://github.com/zertosh/loose-envify) for browserify or DefinePlugin for webpack ( stackoverflow.com/questions/30030031) to ensure you have the correct code for your production build.
new UglifyJsPlugin({
exclude: /node_modules/,
sourceMap: true,
parallel: true,
uglifyOptions: {
ie8: true,
ecma: 6,
},
}),
Answer the question
In order to leave comments, you need to log in
To do a production build, run webpack with the -p option :
or set the process.env.NODE_ENV variable and use the UglifyJsPlugin :
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
}),
new webpack.optimize.UglifyJsPlugin({
// options
}),
plugins: [
new webpack.EnvironmentPlugin(['NODE_ENV']),
new webpack.optimize.UglifyJsPlugin({
// options
}),
],
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
}),
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question