Skip to content

Commit 376a3e9

Browse files
authored
ci: try webpack cache (#6269)
* ci: try webpack cache * Update .github/workflows/testing.yml * Update webpack.prod.mjs * Update package.json * Update testing.yml * Update deploy.yml * fix: use `webpack.*.mjs` * fix: cache key * fix: use cache form common config * Update deploy.yml
1 parent 8171405 commit 376a3e9

File tree

6 files changed

+33
-12
lines changed

6 files changed

+33
-12
lines changed

.github/workflows/deploy.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ jobs:
2323
node-version: ${{ matrix.node-version }}
2424
cache: yarn
2525

26+
- name: Enable webpack persistent caching
27+
uses: actions/cache@v3
28+
id: build-webpack-persistent-cache
29+
with:
30+
path: node_modules/.cache
31+
key: build-${{ hashFiles('**/webpack.*.mjs') }}-${{ hashFiles('**/yarn.lock') }}
32+
restore-keys: |-
33+
build-${{ hashFiles('**/webpack.*.mjs') }}-${{ hashFiles('**/yarn.lock') }}
34+
build-${{ hashFiles('**/webpack.*.mjs') }}-
35+
2636
- run: yarn --frozen-lockfile
2737
- name: Build site
2838
run: yarn build

.github/workflows/testing.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ jobs:
5858

5959
- run: yarn
6060

61+
- name: Enable webpack persistent caching
62+
uses: actions/cache@v3
63+
id: build-webpack-persistent-cache
64+
with:
65+
path: node_modules/.cache
66+
key: build-${{ hashFiles('**/webpack.*.mjs') }}-${{ hashFiles('**/yarn.lock') }}
67+
restore-keys: |-
68+
build-${{ hashFiles('**/webpack.*.mjs') }}-${{ hashFiles('**/yarn.lock') }}
69+
build-${{ hashFiles('**/webpack.*.mjs') }}-
70+
6171
- name: Build site
6272
run: yarn build
6373
env:
@@ -74,6 +84,16 @@ jobs:
7484
steps:
7585
- uses: actions/checkout@v3
7686

87+
- name: Enable webpack persistent caching
88+
uses: actions/cache@v3
89+
id: build-webpack-persistent-cache
90+
with:
91+
path: node_modules/.cache
92+
key: build-${{ hashFiles('**/webpack.*.mjs') }}-${{ hashFiles('**/yarn.lock') }}
93+
restore-keys: |-
94+
build-${{ hashFiles('**/webpack.*.mjs') }}-${{ hashFiles('**/yarn.lock') }}
95+
build-${{ hashFiles('**/webpack.*.mjs') }}-
96+
7797
- name: Cypress run
7898
uses: cypress-io/github-action@v4
7999
with:

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@
5656
"cypress:open": "cypress open",
5757
"cypress:run": "cypress run",
5858
"prettier": "prettier --write '**/*.{js,json,jsx,css,scss,md,mdx}'",
59-
"prepare": "husky install"
59+
"prepare": "husky install",
60+
"postinstall": "rimraf ./node_modules/.cache/webpack"
6061
},
6162
"lint-staged": {
6263
"*.{js,jsx,md,mdx}": [

webpack.common.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export default ({ ssg = false }) => ({
5555
buildDependencies: {
5656
config: [__filename],
5757
},
58-
cacheDirectory: path.resolve(__dirname, '.cache/webpack'),
58+
cacheDirectory: path.resolve(__dirname, 'node_modules/.cache/webpack')
5959
},
6060
resolve: {
6161
extensions: ['.js', '.jsx', '.scss'],

webpack.prod.mjs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ import ProdAssetsManifest from './src/ProdAssetsManifest.mjs';
1515
export default (env) =>
1616
merge(common(env), {
1717
mode: 'production',
18-
cache: {
19-
buildDependencies: {
20-
config: [__filename],
21-
},
22-
},
2318
entry: {
2419
index: {
2520
import: './index.jsx',

webpack.ssg.mjs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ export default (env) =>
2424
name: 'ssg',
2525
mode: 'production',
2626
target: 'node',
27-
cache: {
28-
buildDependencies: {
29-
config: [__filename],
30-
},
31-
},
3227
module: {
3328
parser: {
3429
javascript: {

0 commit comments

Comments
 (0)