javascript - How to provide a configuration file that can be modified by operation and maintenance for a front-end project compiled by webpack?
巴扎黑
巴扎黑 2017-05-19 10:15:02
0
2
441

The project needs to use a url constant, which may change according to actual operation and maintenance conditions.
Now when the url changes, I need to change the source code and recompile.
If you don't use webpack, this problem will not occur. Just tell the operation and maintenance the path to the configuration file.
But when using webpack, is there any way to avoid this situation and allow operation and maintenance to modify the configuration?

巴扎黑
巴扎黑

reply all(2)
我想大声告诉你

Put the configuration items separately in a json, and read the configuration in this json first when running the project.

  • You can load this json file through ajax/xhr/fetch/amd, there are many ways;

  • At this time, we need to consider a performance issue. Make good use of cache/cookie/localStorage so that you don’t have to reload the json file every time.

我想大声告诉你

Our project approach is to configure multiple configuration files for development, testing and production

Different environments use different configurations

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template