Skip to content

Commit 51ee462

Browse files
committed
add cache in CI/CD description
1 parent 7dce83b commit 51ee462

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/content/configuration/cache.mdx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,3 +438,30 @@ module.exports = {
438438
```
439439

440440
W> Don't share the cache between calls with different options.
441+
442+
## Setup cache in CI/CD system
443+
444+
Filesystem cache allows to share cache between builds in CI. To setup cache:
445+
446+
- CI should have an option to share cache between builds.
447+
- CI should run job in the same absolute path. This is important since webpack cache files store absolute paths.
448+
449+
### GitLab CI/CD
450+
451+
Common config could looks like
452+
453+
```yaml
454+
variables:
455+
# fallback to use "main" branch cache, requires GitLab Runner 13.4
456+
CACHE_FALLBACK_KEY: main
457+
458+
# this is webpack build job
459+
build-job:
460+
cache:
461+
key: '$CI_COMMIT_REF_SLUG' # branch/tag name
462+
paths:
463+
# cache directory
464+
# make sure that you don't run "npm ci" in this job or change default cache directory
465+
# otherwise "npm ci" will prune cache files
466+
- node_modules/.cache/webpack/
467+
```

0 commit comments

Comments
 (0)