Skip to content

Commit 63c0afd

Browse files
committed
Cache Vite optimized deps across CI runs
Move Vite's deps cache from node_modules/.vite/ (wiped by npm ci) to a repo-root .vite/ directory and persist it via actions/cache, keyed on package-lock.json + astro.config.mjs. Modest savings (~5-15s per job) since production builds rely more on Rollup's in-process cache than the deps optimizer, but the cache is free and survives lockfile-stable runs.
1 parent 64c9331 commit 63c0afd

4 files changed

Lines changed: 37 additions & 0 deletions

File tree

.github/workflows/s3-deploy-development.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ jobs:
2424
key: astro-dev-en-${{ github.sha }}
2525
restore-keys: astro-dev-en-
2626

27+
- name: Cache Vite deps
28+
uses: actions/cache@v4
29+
with:
30+
path: .vite
31+
key: vite-${{ hashFiles('package-lock.json', 'astro.config.mjs') }}
32+
restore-keys: vite-
33+
2734
- run: npm ci
2835
env:
2936
PUPPETEER_SKIP_DOWNLOAD: '1'
@@ -67,6 +74,13 @@ jobs:
6774
key: astro-dev-${{ matrix.locale }}-${{ github.sha }}
6875
restore-keys: astro-dev-${{ matrix.locale }}-
6976

77+
- name: Cache Vite deps
78+
uses: actions/cache@v4
79+
with:
80+
path: .vite
81+
key: vite-${{ hashFiles('package-lock.json', 'astro.config.mjs') }}
82+
restore-keys: vite-
83+
7084
- run: npm ci
7185
env:
7286
PUPPETEER_SKIP_DOWNLOAD: '1'

.github/workflows/s3-deploy-production.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ jobs:
7979
key: astro-en-${{ github.sha }}
8080
restore-keys: astro-en-
8181

82+
- name: Cache Vite deps
83+
uses: actions/cache@v4
84+
with:
85+
path: .vite
86+
key: vite-${{ hashFiles('package-lock.json', 'astro.config.mjs') }}
87+
restore-keys: vite-
88+
8289
- run: npm ci
8390
env:
8491
PUPPETEER_SKIP_DOWNLOAD: '1'
@@ -123,6 +130,13 @@ jobs:
123130
key: astro-${{ matrix.locale }}-${{ github.sha }}
124131
restore-keys: astro-${{ matrix.locale }}-
125132

133+
- name: Cache Vite deps
134+
uses: actions/cache@v4
135+
with:
136+
path: .vite
137+
key: vite-${{ hashFiles('package-lock.json', 'astro.config.mjs') }}
138+
restore-keys: vite-
139+
126140
- run: npm ci
127141
env:
128142
PUPPETEER_SKIP_DOWNLOAD: '1'
@@ -217,6 +231,13 @@ jobs:
217231
key: astro-${{ matrix.locale }}-${{ github.sha }}
218232
restore-keys: astro-${{ matrix.locale }}-
219233

234+
- name: Cache Vite deps
235+
uses: actions/cache@v4
236+
with:
237+
path: .vite
238+
key: vite-${{ hashFiles('package-lock.json', 'astro.config.mjs') }}
239+
restore-keys: vite-
240+
220241
- run: npm ci
221242
env:
222243
PUPPETEER_SKIP_DOWNLOAD: '1'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# Generated files
99
.docusaurus
1010
.cache-loader
11+
.vite
1112

1213
# Misc
1314
.DS_Store

astro.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export default defineConfig({
2727
inlineStylesheets: 'never',
2828
},
2929
vite: {
30+
cacheDir: '.vite',
3031
plugins: [
3132
tailwindcss(),
3233
],

0 commit comments

Comments
 (0)