What is
Run cross-platform settings and environment variables using a script
The reason
When you use NODE_ENV = production, to set environment variables, most of the Windows command prompt will block (error). (Exceptions are Bash on Windows, it uses the machine Bash.) Similarly, Windows and POSIX command how to use the environment variables are different. Use POSIX, you can use: $ ENV_VAR% ENV_VAR% and the use of Windows.
windows does not support NODE_ENV = set way of development.
solve
cross-env enables you to use a single command, without having to worry about setting environment variables or by using the correct platform. Just run on POSIX systems can be set up, while cross-env will set it up correctly.
Talking: This mini-package (cross-env) provides a set environment variables scripts, so you can set the environment variable to unix way, and is also compatible to run on windows.
installation
npm install --save-dev cross-env
use
{"scripts":{"build":"cross-env NODE_ENV=production webpack --config build/webpack.config.js"}}
NODE_ENV environment variables set by the cross-env
打印process.env.NODE_ENV === 'production '