Skip to content

Commit 6dcf110

Browse files
authored
enable babel-loader cache (#10083)
this speeds up repeated webpack builds by around 20%. It will use the default cache directory `node_modules/.cache/babel-loader`. Also added cache invalidation to workaround babel/babel-loader#690
1 parent 3ccd271 commit 6dcf110

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ $(FOMANTIC_DEST_DIR): semantic.json web_src/fomantic/theme.config.less | node_mo
509509
.PHONY: webpack
510510
webpack: node-check $(WEBPACK_DEST)
511511

512-
$(WEBPACK_DEST): $(WEBPACK_SOURCES) | node_modules
512+
$(WEBPACK_DEST): $(WEBPACK_SOURCES) webpack.config.js | node_modules
513513
npx eslint web_src/js webpack.config.js
514514
npx stylelint web_src/less
515515
npx webpack --hide-modules --display-entrypoints=false

webpack.config.js

+8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const PostCSSPresetEnv = require('postcss-preset-env');
77
const PostCSSSafeParser = require('postcss-safe-parser');
88
const TerserPlugin = require('terser-webpack-plugin');
99
const VueLoaderPlugin = require('vue-loader/lib/plugin');
10+
const { statSync } = require('fs');
1011
const { resolve, parse } = require('path');
1112
const { SourceMapDevToolPlugin } = require('webpack');
1213

@@ -84,6 +85,13 @@ module.exports = {
8485
{
8586
loader: 'babel-loader',
8687
options: {
88+
cacheDirectory: true,
89+
cacheCompression: false,
90+
cacheIdentifier: [
91+
resolve(__dirname, 'package.json'),
92+
resolve(__dirname, 'package-lock.json'),
93+
resolve(__dirname, 'webpack.config.js'),
94+
].map((path) => statSync(path).mtime.getTime()).join(':'),
8795
presets: [
8896
[
8997
'@babel/preset-env',

0 commit comments

Comments
 (0)