I need to dynamically set the connection address of the server according to whether I am running dev or a built process, because I also need to set up a backup server and the like. It is very inconvenient to set up multiple places every time, but I don’t understand it. How to find out whether it is running dev or build, solved, thank you~~~
我想大声告诉你2017-05-19 10:27:09
if (process.env.NODE_ENV === 'development') {
// dev
} else {
// build
}
仅有的幸福2017-05-19 10:27:09
You can set the environment in npm script, and then you can judge as mentioned above
"script": {
"build": "cross-env NODE_ENV=production webpack --hide-modules --colors --progress --config=build/prod.conf.js",
}