When packing under nuxt, I want to tell whether I am running npm run dev or build or the newly created script command. How can I tell the difference?

the packaged scripts are generated dynamically by nuxt. How to mark a global variable so that your business code can tell which command it is? (for example, the interface domain names of different commands are different)


customize a global variable, or use cross-env to set a variable when executing the script command, for example: "build:web": "cross-env BUILD_TARGET=web node. Electron-vue/build.js" , Can't you judge with process.env.BUILD_TARGET


https://zh.nuxtjs.org/api/con.
process.env.NODE_ENV in the business code?

Menu