Hey,
By default webpacker use this path to save cache:
tmp/cache/webpacker
https://github.com/rails/webpacker/blob/master/lib/install/config/webpacker.yml#L8
the cache from the babel-loader gets into this folder:
https://github.com/rails/webpacker/blob/master/package/rules/node_modules.js#L17
https://github.com/rails/webpacker/blob/master/package/rules/babel.js#L15
But most js libraries use node_modules/.cache:
babel-loader:
https://github.com/babel/babel-loader#options
the loader will use the default cache directory in node_modules/.cache/babel-loader
or fallback to the default OS temporary file directory if no node_modules
folder could be found in any root directory.
terser-webpack-plugin
https://github.com/webpack-contrib/terser-webpack-plugin#cache
Enable file caching. Default path to cache directory:
node_modules/.cache/terser-webpack-plugin.
compression-webpack-plugin
https://github.com/webpack-contrib/compression-webpack-plugin#cache
Enable file caching. The default path to cache directory:
node_modules/.cache/compression-webpack-plugin.
Webpack 5
https://webpack.js.org/configuration/other-options/#cachecachedirectory
Base directory for the cache. Defaults to node_modules/.cache/webpack.
I saw the comment from @jakeNiemiec
https://github.com/rails/webpacker/issues/2178#issuecomment-511898515
cache_path can be changed to node_modules/.cache
Is there any reason why cache_path has tmp/cache/webpacker value by default?
This speed up my build times in Circle from 5 minutes down to 2 minutes because I wasn't caching the tmp directory. It's a quick win.
Most helpful comment
This speed up my build times in Circle from 5 minutes down to 2 minutes because I wasn't caching the tmp directory. It's a quick win.