diff --git a/.github/workflows/deploy-docs-preview.yml b/.github/workflows/deploy-docs-preview.yml index c5fd3fbaa2..f1943ff312 100644 --- a/.github/workflows/deploy-docs-preview.yml +++ b/.github/workflows/deploy-docs-preview.yml @@ -37,9 +37,27 @@ jobs: working-directory: docs cache-dependency-path: docs/pnpm-lock.yaml + - name: Restore docs Vite Task cache + id: vite-task-cache + uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6 + with: + path: docs/node_modules/.vite/task-cache + key: vite-task-docs-${{ runner.os }}-${{ runner.arch }}-pr-${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }} + # Prefer this PR's newest cache, then fall back to main for new PRs. + restore-keys: | + vite-task-docs-${{ runner.os }}-${{ runner.arch }}-pr-${{ github.event.pull_request.number }}- + vite-task-docs-${{ runner.os }}-${{ runner.arch }}-main- + - run: vp run build working-directory: docs + - name: Save docs Vite Task cache + if: success() && steps.vite-task-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6 + with: + path: docs/node_modules/.vite/task-cache + key: ${{ steps.vite-task-cache.outputs.cache-primary-key }} + - run: vpx void deploy --dir docs/.vitepress/dist env: VOID_TOKEN: ${{ secrets.VOID_TOKEN }} diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index 2d3d7f63d0..5fb616d325 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -37,9 +37,26 @@ jobs: working-directory: docs cache-dependency-path: docs/pnpm-lock.yaml + - name: Restore docs Vite Task cache + id: vite-task-cache + uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6 + with: + path: docs/node_modules/.vite/task-cache + key: vite-task-docs-${{ runner.os }}-${{ runner.arch }}-main-${{ github.sha }} + # Restore the latest main cache; Vite Task fingerprints decide reuse. + restore-keys: | + vite-task-docs-${{ runner.os }}-${{ runner.arch }}-main- + - run: vp run build working-directory: docs + - name: Save docs Vite Task cache + if: success() && steps.vite-task-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6 + with: + path: docs/node_modules/.vite/task-cache + key: ${{ steps.vite-task-cache.outputs.cache-primary-key }} + - run: vpx void deploy --dir docs/.vitepress/dist env: VOID_TOKEN: ${{ secrets.VOID_TOKEN }} diff --git a/docs/package.json b/docs/package.json index 0a04318a97..579714aa07 100644 --- a/docs/package.json +++ b/docs/package.json @@ -4,7 +4,8 @@ "type": "module", "scripts": { "dev": "vitepress dev", - "build": "cp ../packages/cli/install.sh ../packages/cli/install.ps1 public/ && vitepress build", + "build": "cp ../packages/cli/install.sh ../packages/cli/install.ps1 public/ && vp run build:site", + "build:netlify": "cp ../packages/cli/install.sh ../packages/cli/install.ps1 public/ && vitepress build", "preview": "vitepress preview", "update-trusted-stack-stats": "node .vitepress/theme/data/fetch-trusted-stack-stats.ts" }, diff --git a/docs/vite.config.ts b/docs/vite.config.ts new file mode 100644 index 0000000000..217728eb50 --- /dev/null +++ b/docs/vite.config.ts @@ -0,0 +1,17 @@ +export default { + run: { + tasks: { + 'build:site': { + command: 'vitepress build', + input: [ + { auto: true }, + '!.vitepress/.temp/**', + '!.vitepress/dist/**', + '!node_modules', + '!node_modules/.vite-temp/**', + ], + output: ['.vitepress/dist/**'], + }, + }, + }, +}; diff --git a/netlify.toml b/netlify.toml index 9b76ffa616..988c5ab2dc 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,6 +1,6 @@ [build] base = "docs/" -command = "pnpm build" +command = "pnpm build:netlify" publish = ".vitepress/dist" # Windows installer redirect