search

Home  >  Q&A  >  body text

javascript - In vue webpack, how to determine whether to run dev or run build?

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

怪我咯怪我咯2775 days ago943

reply all(2)I'll reply

  • 我想大声告诉你

    我想大声告诉你2017-05-19 10:27:09

    if (process.env.NODE_ENV === 'development') {
        // dev
    } else {
        // build
    }

    reply
    0
  • 仅有的幸福

    仅有的幸福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",
    }
    

    reply
    0
  • Cancelreply