Using cache to improve the speed of secondary construction in webpack

Time:2020-11-11

1. Babel loader enables caching

Description in official documents: https://webpack.docschina.org…
Cachedirectory: the default value is false. When there are settings, the specified directory will be used to cache the execution results of the loader. After the webpack build, it will try to read the cache to avoid the Babel recompilation process which may cause high performance consumption during each execution. If you set a null value (loader: ‘Babel loader? Cachedirectory’) or true (loader: ‘Babel loader? Cachedirectory = true’), the loader will use the default cache directory node_ Modules /. Cache / Babel loader, if no node is found in any root directory_ The modules directory will be demoted back to the default temporary file directory of the operating system.
After the cache is enabled, the_ Under modules, you can see a. Cache file

It is found that the way mentioned on the official website does not take effect. It needs to be modified to be written in option
Using cache to improve the speed of secondary construction in webpack

2. Terser webpack plugin enables caching

Using cache to improve the speed of secondary construction in webpack
Parallel is the use of multi process parallel running, which can improve the construction speed and significantly improve the construction speed
Cache enables file caching. Default path of cache directory: node_ modules/.cache/terser-webpack-plugin。
This configuration is the same as webplugin.

3.hard-source-webpack-plugin

Using cache to improve the speed of secondary construction in webpack
Node is used to provide intermediate cache step for module_ Under modules /. Cache / hard source, it can significantly improve the speed of construction!!

Recommended Today

Summary of recent use of gin

Recently, a new project is developed by using gin. Some problems are encountered in the process. To sum up, as a note, I hope it can help you. Cross domain problems Middleware: func Cors() gin.HandlerFunc { return func(c *gin.Context) { //Here you can use * or the domain name you specify c.Header(“Access-Control-Allow-Origin”, “*”) //Allow header […]