How does vue+webpack realize the packaging and switching of development, testing, production and other environments?

projects built by vue-cli+webpack. Npm run build has to manually distinguish between test and production environments every time it is packaged. How to configure automatic differentiation? For example, I need to distinguish between assetsPublicPath:"/", the packaged path is different, the api of the proxy proxy is different, and so on. Ask the great god for advice. Thank you


npm provides a npm_lifecycle_event variable that returns the name of the currently running script

The most common use of

DefinePlugin is to deal with the differences between our development and production environments.

you can use both

Menu