WEBAPCK on-demand load and version control issues

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.