After you enable lazy loading of webpack (load on demand), we encounter issues to resolve the cache.
There are several ways to troubleshoot caching problems:
The first is the addition of a hash value. The file name is not the same after each modification. This will achieve the desired effect of resolving the cache. Specific settings such as:
This solution can achieve the effect of engineering management in Webpack. However, there will be some obstacles to project management. such as Git to manage the project, each compilation will delete the last compiled file, and then to add the compiled file and then push.
The second method is more violent. The hash value is not added so that each compilation gets the same file name as the configuration:
All we have to do is find the compiled entry file, then find the lazy loading method and modify it, such as adding a random number, as follows:
In the compiled portal file, look for "document.getElementsByTagName (" Head ") [0], find its add-on, the modified file:
Modified file:
This way the loaded file will have a random number to ensure that the cache is in question, as follows:
However, this method is also a disadvantage, that is, every compilation to manually modify the entry file. But for GIT project management is better management, do not have to add delete every time.
Both of the two methods are pros and cons, specifically what to use the solution to see how you choose. Of course, there may be a better solution, if you know the students trouble to tell me.
WEBAPCK on-demand load and version control issues