Production and test environments are packaged in different modes

The first step

Add packaging mode to package.jsonExample above: Build: ProD production environment packaging

Build :stage test environment package

The second step

Add.env.staging files and.env.production filesConfigure environment variables in the file: NODE_ENV=test, NODE_ENV=prod

The third step

The interface domain name cannot be written dead. If the interface domain name is packaged, it cannot be dynamically distinguished between the production environment and the test environment. Write this as the configured environment variable name based on the environment variable we configured in step 2;

The fourth step

Production package: NPM run build:prod Test package: NPM run build:stage Package interface is the corresponding file configuration environment variables ~

One day

The.env.staging files and.env.production need to be set to config after NODE_ENV is packaged.