【发布时间】:2021-04-15 21:52:59
【问题描述】:
用于缓存 (type: 'filesystem'),当我使用时
buildDependencies: {
config: [__filename],
}
并在进行最小更改后重建,我得到了要使用的缓存:
[webpack.cache.PackFileCacheStrategy] restore cache container: 75.650361 ms
[webpack.cache.PackFileCacheStrategy] check build dependencies: 38.511852 ms
[webpack.cache.PackFileCacheStrategy] restore cache content metadata: 7.851668 ms
但是,如果我只是向buildDependencies 添加一个文件,例如像这样(相同,如果我使用新属性):
buildDependencies: {
config: [__filename, path.resolve(__dirname, 'tsconfig.json')],
}
我突然得到一个缓存失效(虽然tsconfig.json没有改变,webpack.config.js也没有,我显然在两者之间重建):
[webpack.cache.PackFileCacheStrategy] restore cache container: 79.482314 ms
[webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] C:\some\nice\folder invalidated because hashes differ (somehash != someotherhash)
[webpack.cache.PackFileCacheStrategy] Restored pack from C:\some\nice\folder\cachefolder\cachename.pack, but build dependencies have changed.
[webpack.cache.PackFileCacheStrategy] check build dependencies: 593.564325 ms
请注意,它提到以文件夹(项目文件夹)结尾的路径无效,尽管我应该将文件指定为依赖项。生成的构建时间大约是原来的两倍。
我在这里做错了什么?为什么webpack这里的缓存无效,虽然没有任何依赖改变?
【问题讨论】:
标签: javascript node.js webpack