javascript - In vue webpack, how to determine whether to run dev or run build?
怪我咯
怪我咯 2017-05-19 10:25:09
0
2
938

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~~~

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(2)
我想大声告诉你
if (process.env.NODE_ENV === 'development') {
    // dev
} else {
    // build
}
仅有的幸福

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",
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template