Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions docs/guide/ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,21 @@ The GitHub Action sets up Vite+, the required Node.js version, and the package m
with:
node-version: '24'
cache: true
task-cache: true
- run: vp install
- run: vp check
- run: vp test
- run: vp build
```

With `cache: true`, `setup-vp` handles dependency caching for you automatically.
### Caching

::: tip
`setup-vp` caches package-manager data. To reuse Vite Task results across CI runs, add a separate [GitHub Actions cache for Vite Task](/guide/github-actions-cache).
:::
Vite+ offers two different caching functions which interact with GitHub Actions Cache.

- With `cache: true`, `setup-vp` handles dependency caching for you automatically.
- You can manually choose the lockfile manifest with `cache-dependency-path`, leaving it blank will auto-infer it for you.
- With `task-cache: true`, `setup-vp` handles saving and restoring the Vite+ task cache between runs for you.
- Please read the [GitHub Actions Cache](/guide/github-actions-cache) page to learn more.

## GitLab CI/CD

Expand Down
38 changes: 36 additions & 2 deletions docs/guide/github-actions-cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
Reusing Vite Task's cache across GitHub Actions runs is experimental. Test and measure it in your project before relying on it in CI.
:::

::: tip `setup-vp` support
The `setup-vp` action supports saving to GitHub Actions Cache with pre-wired defaults.
Continue reading to learn how to set up.

In either case, you will still need to follow most instructions on this page.
:::

Vite Task stores task results in `node_modules/.vite/task-cache` at the workspace root. Restore that directory in later GitHub Actions runs so Vite Task can reuse previous task results.

GitHub Actions cache and Vite Task make separate decisions:
Expand Down Expand Up @@ -61,12 +68,39 @@ vp run lint # should print "cache hit"

## 2. Restore The Cache After Install

Restore `node_modules/.vite/task-cache` after `vp install`, because package installation can recreate or modify `node_modules`.
Use the `task-cache` toggle to enable saving the task cache to GitHub Actions Cache.
It will use the key configuration seen later on this page.

Set `<setup-vp-version>` below to an exact version from the [`setup-vp` releases page](https://github.com/voidzero-dev/setup-vp/releases). You can use a commit SHA instead.
Set `<setup-vp-version>` below to an exact version from the [`setup-vp` releases page](https://github.com/voidzero-dev/setup-vp/releases). You can also use a commit SHA instead, which can pin the action to a specific build.

See [Automatic Version Updates](/guide/ci#automatic-version-updates) to configure Dependabot or Renovate.

```yaml
name: CI

on:
pull_request:
push:
branches: [main]

permissions:
contents: read

jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: voidzero-dev/setup-vp@<setup-vp-version>
with:
node-version: '24'
cache: true
task-cache: true
```

Otherwise, remember to restore `node_modules/.vite/task-cache` after `vp install`, because package installation can recreate or modify `node_modules`.

```yaml [.github/workflows/ci.yml]
name: CI

Expand Down
Loading