webpack-tricks icon indicating copy to clipboard operation
webpack-tricks copied to clipboard

Webpack 2: -p option does not set NODE_ENV to "production" in webpack config

Open Fadingvision opened this issue 7 years ago • 0 comments

the README said:

Webpack 2: Invoke Webpack as webpack -p when building your production assets. NODE_ENV is automatically set by Webpack.

I think there's something wrong. from the webpack offical doc and #2537:

Technically, NODE_ENV is a system environment variable that Node.js exposes into running scripts. It is used by convention to determine development-vs-production behavior by server tools, build scripts, and client-side libraries. Contrary to expectations, process.env.NODE_ENV is not set to "production" within the build script webpack.config.js, see #2537. Thus, conditionals like process.env.NODE_ENV === 'production' ? '[name].[hash].bundle.js' : '[name].bundle.js' do not work as expected. See how to use environment variables. link

Fadingvision avatar Aug 02 '17 08:08 Fadingvision