Skip to content

Commit

Permalink
bug #905 Omit cache key entirely when build cache is disabled (weaver…
Browse files Browse the repository at this point in the history
…ryan)

This PR was merged into the main branch.

Discussion
----------

Omit cache key entirely when build cache is disabled

Fixes an issue where `yarn watch` or `yarn dev-server` had super slow "rebuilds" - as long as the initial build, which is much different than the pre-1.0 version of Encore.

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

Commits
-------

9282c77 omit cache key entirely when build cache is disabled
  • Loading branch information
weaverryan committed Jan 31, 2021
2 parents 54fa794 + 9282c77 commit 9fd5f05
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/config-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,14 @@ class ConfigGenerator {
},
plugins: this.buildPluginsConfig(),
optimization: this.buildOptimizationConfig(),
cache: this.buildCacheConfig(),
watchOptions: this.buildWatchOptionsConfig(),
devtool: false,
};

if (this.webpackConfig.usePersistentCache) {
config.cache = this.buildCacheConfig();
}

if (this.webpackConfig.useSourceMaps) {
if (this.webpackConfig.isProduction()) {
// https://webpack.js.org/configuration/devtool/#for-production
Expand Down Expand Up @@ -511,10 +514,6 @@ class ConfigGenerator {
}

buildCacheConfig() {
if (!this.webpackConfig.usePersistentCache) {
return false;
}

const cache = {};

cache.type = 'filesystem';
Expand Down

0 comments on commit 9fd5f05

Please sign in to comment.