Skip to content

feat: Cloudflare Pages support for hosting#2570

Open
ArthurDanjou wants to merge 1 commit into
mainfrom
feat/cloudflare-host-support
Open

feat: Cloudflare Pages support for hosting#2570
ArthurDanjou wants to merge 1 commit into
mainfrom
feat/cloudflare-host-support

Conversation

@ArthurDanjou
Copy link
Copy Markdown

Auto-detect wrangler.toml or wrangler.json and generate a _headers file with long-term caching for /assets/*.

Update _redirects output for SPA and add Cloudflare Pages docs and local Wrangler preview examples.

Auto-detect wrangler.toml or wrangler.json and generate a _headers
file with long-term caching for /assets/*. Update _redirects output for
SPA and add Cloudflare Pages docs and local Wrangler preview examples.
Copilot AI review requested due to automatic review settings April 29, 2026 16:46
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 29, 2026

Deploy Preview for slidev ready!

Name Link
🔨 Latest commit 78ee3ea
🔍 Latest deploy log https://app.netlify.com/projects/slidev/deploys/69f235fd8cc9370008b59d40
😎 Deploy Preview https://deploy-preview-2570--slidev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 29, 2026

Open in StackBlitz

@slidev/client

npm i https://pkg.pr.new/@slidev/client@2570

create-slidev

npm i https://pkg.pr.new/create-slidev@2570

create-slidev-theme

npm i https://pkg.pr.new/create-slidev-theme@2570

@slidev/parser

npm i https://pkg.pr.new/@slidev/parser@2570

@slidev/cli

npm i https://pkg.pr.new/@slidev/cli@2570

@slidev/types

npm i https://pkg.pr.new/@slidev/types@2570

commit: 78ee3ea

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class Cloudflare Pages guidance and output tweaks so Slidev-built decks work well on Cloudflare Pages (SPA redirects + long-term caching for hashed assets).

Changes:

  • Document Cloudflare Pages deployment + local preview via Wrangler in both the main hosting guide and skills reference docs.
  • Update generated _redirects output to include an explicit index.html rule plus SPA fallback.
  • Auto-detect wrangler.toml / wrangler.json and generate a _headers file to set long-term caching on /assets/*.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
skills/slidev/references/core-hosting.md Adds Cloudflare Pages deployment + Wrangler local preview instructions.
packages/slidev/node/commands/build.ts Updates _redirects generation and adds Cloudflare Pages _headers generation when Wrangler config is present.
docs/guide/hosting.md Adds Cloudflare Pages section and explains the generated _redirects / _headers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

const base = config.base
await fs.writeFile(
redirectsPath,
`${base}index.html ${base}index.html 200\n${base}* ${base}index.html 200\n`,
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generated _redirects file includes a rule rewriting ${base}index.html to itself. This doesn’t add behavior beyond the ${base}* -> ${base}index.html SPA fallback (which already covers requests for ${base}index.html) and makes the output more verbose than necessary. Consider dropping the no-op index.html -> index.html rule and keeping only the SPA fallback rule.

Suggested change
`${base}index.html ${base}index.html 200\n${base}* ${base}index.html 200\n`,
`${base}* ${base}index.html 200\n`,

Copilot uses AI. Check for mistakes.
if (hasWranglerConfig) {
const headersPath = resolve(outDir, '_headers')
if (!existsSync(headersPath)) {
await fs.writeFile(headersPath, `\n/assets/*\n Cache-Control: public, max-age=31536000, immutable\n`, 'utf-8')
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generated _headers rule is hard-coded to /assets/*. If config.base is set for subdirectory deployments (e.g. /my-slides/), requests will be under ${config.base}assets/... and this rule won’t match, so the long-term caching won’t apply. Consider prefixing the pattern with config.base (e.g. ${config.base}assets/*) and dropping the initial blank line in the file content.

Suggested change
await fs.writeFile(headersPath, `\n/assets/*\n Cache-Control: public, max-age=31536000, immutable\n`, 'utf-8')
await fs.writeFile(headersPath, `${config.base}assets/*\n Cache-Control: public, max-age=31536000, immutable\n`, 'utf-8')

Copilot uses AI. Check for mistakes.
Comment thread docs/guide/hosting.md

Slidev automatically detects when you are deploying to [Cloudflare Pages](https://pages.cloudflare.com/) by looking for a `wrangler.toml` or `wrangler.json` file in your project root.

When detected, Slidev generates the necessary `_redirects` and `_headers` files for optimal SPA hosting.
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This paragraph implies _redirects generation is conditional on Cloudflare Pages detection, but _redirects is generated unconditionally during slidev build (only skipped if the file already exists). Consider rephrasing to say that detection adds _headers generation, while _redirects is generated for SPA hosting in general.

Suggested change
When detected, Slidev generates the necessary `_redirects` and `_headers` files for optimal SPA hosting.
For SPA hosting, Slidev generates the necessary `_redirects` file during `slidev build` (unless it already exists). When Cloudflare Pages is detected, Slidev also generates the `_headers` file for optimal deployment.

Copilot uses AI. Check for mistakes.
@ArthurDanjou ArthurDanjou changed the title Add Cloudflare Pages support for hosting feat: Cloudflare Pages support for hosting Apr 29, 2026
@ArthurDanjou ArthurDanjou requested a review from antfu May 4, 2026 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants