Background:

In company-level development, it is often necessary to separate the development environment from the production environment. For example, the development environment requires some debugger and console operations, and the production environment requires some permission verification. These can be distinguished by patterns.

Overview of vuE-CLI mode:

When building a project with webpack, process.env.node_env is used to determine which mode to use. Common modes are development and production.

In earlier vuE-CLI versions, the Webpack option was exposed with different configuration files representing different modes

The webpack.prod.conf.js file is defined, build.js introduces the webpack.prod.conf.js configuration file, and then uses build.js for schema packaging in package JSON

In vuE-Cli4, webpack options are hidden, you can see that there is no build folder or config folder, and the startup command is different from the previous version. Default development and production patterns

If you want to customize the mode, you need to create the corresponding mode configuration file. You can define any variable name rule as.env.[Any name]

Then specify the schema in package.json

The model of

You can specify the display in a template using a defined pattern

You can also use a specified pattern to execute a piece of logic in code