Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment to Cloudflare pages #6

Open
debuggingfuture opened this issue Dec 13, 2024 · 0 comments
Open

Deployment to Cloudflare pages #6

debuggingfuture opened this issue Dec 13, 2024 · 0 comments

Comments

@debuggingfuture
Copy link
Member

Background

Astro supports cloudflare page deployment
However it turns out it is very ticky to handle dependency properly for ssr site

https://developers.cloudflare.com/pages/framework-guides/deploy-an-astro-site/

Sample Setup

Analysis

  • It is under impression that wrangler will apply unenv according to docs here
    • however if astro is used to build, wrangler will just take it as-is
    • it is possible to explicit apply unenv inside astro config and setup cloudflare preset
    • issues:
      • unenv cloudflare preset evolved quite a bit since v1.10.0 release (https://github.com/unjs/unenv/tree/main). Use git to resolve for latest branch

      • config has to run in 3 runtimes

        1. astro server e.g. static paths
        2. astro server routes (run as cloudflare functions)
        3. browser, for the client component (client:only="react")
      • if cloudflare preset is not used, server routes will be missing dependencies.

      • if cloudflare preset is used, it can build but as astro bundle react & dependencies in chunk, client component will get errors like "process is not defined" as it try to run the cloudflare shim versions too

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

No branches or pull requests

1 participant