cache-loader-hash
v4.1.6
Published
Caches the result of following loaders on disk.
Downloads
16
Readme
cache-loader-hash
Added the mode option to the cache-loader
options, supporting mtime
(default) and hash
.
Usage
npm install cache-loader-hash --save-dev
const CacheLoaderHash = require.resolve('@datafe/cache-loader-hash');
webpackChain.module.rules
.values()
.filter((rule) => rule.uses.has('cache-loader'))
.forEach((rule) => {
rule
.use('cache-loader')
.loader(CacheLoaderHash)
.tap((options) => {
options.mode = 'hash';
return options;
});
});
No Breaking Change
No breaking change when using mtime
mode.
Why
We are doing a CI package acceleration work, which will store node_modules/.cache
on s3
, and then pull it from s3
at a certain time. due to
The cache-loader uses mtime
by default for cache verification, which causes the newly installed node_modules in the new CI process to not match the mtime
of node_modules/.cache
on s3
. The solution to this problem is to use the hash of the file instead of mtime as the cache verification method of the cache-loader.
License
MIT