How does react package without packaging configuration files using webpack?

problem description

because the development environment is different from the test environment, some configuration parameters are put into a separate file. Each package in the development environment and test environment needs to be modified and submitted separately, and then packaged, which is very troublesome.

is there any way to make the js files of these configuration classes not packaged and can still be used after packaging? you can change these files directly in different environments.

Development environment

react, webpack, dva


each environment is configured with a separate configuration file. Different environments execute different packaging commands, and different configuration files are introduced.


if (process.env.NODE_ENV = 'test') {
require (' test.config.js')
} else if (process.env.NODE_ENV = 'pro') {
require (' pro.config.js')
}


code split types the configuration into a separate js file, inevitably with some compiled code, but this is already the best solution to build on webpack .

or skip webpack, and just use script to introduce it. The only disadvantage is that the configuration is exposed to a global variable, and cannot use webpack closures

.
Menu