From f538b53813ef4e6255a8988bf10a1674c1ea0605 Mon Sep 17 00:00:00 2001 From: Jerome Leclanche Date: Tue, 3 Sep 2019 13:09:32 +0200 Subject: [PATCH] Disable babel-loader's cacheCompression `cacheCompression` is an enabled-by-default flag in babel-loader, which gzips the babel-loader cache. Most projects do not actually benefit from cache compression, especially in production where builds often happen in a CI environment where memory is precious and disk space is not. Furthermore, having it disabled in dev and enabled in prod means caching won't be shared between dev and prod. Finally, the disk space savings are not that great. Most React projects will have a lot of small files (one file per component). babel-loader caches each file as a unit, so the compression overhead increases when the project is mainly lots of small files. For these reasons, we're disabling cache compression. Closes #6846 --- packages/react-scripts/config/webpack.config.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.js b/packages/react-scripts/config/webpack.config.js index 12157a390b8..41a9f5e5438 100644 --- a/packages/react-scripts/config/webpack.config.js +++ b/packages/react-scripts/config/webpack.config.js @@ -429,7 +429,8 @@ module.exports = function(webpackEnv) { // It enables caching results in ./node_modules/.cache/babel-loader/ // directory for faster rebuilds. cacheDirectory: true, - cacheCompression: isEnvProduction, + // See #6846 for context on why cacheCompression is disabled + cacheCompression: false, compact: isEnvProduction, }, }, @@ -450,7 +451,8 @@ module.exports = function(webpackEnv) { ], ], cacheDirectory: true, - cacheCompression: isEnvProduction, + // See #6846 for context on why cacheCompression is disabled + cacheCompression: false, // @remove-on-eject-begin cacheIdentifier: getCacheIdentifier( isEnvProduction