Skip to content

Commit 9282c77

Browse files
committed
omit cache key entirely when build cache is disabled
It appears that cache: false is different than omitting the cache key entirely. Using cache: false appears to even disable in-memory caching that Webpack does when rebuilding in "watch" mode or for the dev-server
1 parent 54fa794 commit 9282c77

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lib/config-generator.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,14 @@ class ConfigGenerator {
6767
},
6868
plugins: this.buildPluginsConfig(),
6969
optimization: this.buildOptimizationConfig(),
70-
cache: this.buildCacheConfig(),
7170
watchOptions: this.buildWatchOptionsConfig(),
7271
devtool: false,
7372
};
7473

74+
if (this.webpackConfig.usePersistentCache) {
75+
config.cache = this.buildCacheConfig();
76+
}
77+
7578
if (this.webpackConfig.useSourceMaps) {
7679
if (this.webpackConfig.isProduction()) {
7780
// https://webpack.js.org/configuration/devtool/#for-production
@@ -511,10 +514,6 @@ class ConfigGenerator {
511514
}
512515

513516
buildCacheConfig() {
514-
if (!this.webpackConfig.usePersistentCache) {
515-
return false;
516-
}
517-
518517
const cache = {};
519518

520519
cache.type = 'filesystem';

0 commit comments

Comments
 (0)