Skip to content

[🐞] Cloudflare Pages: Ability to run cloudflare pages dev server with vite #307

@sujith97

Description

@sujith97

Which component is affected?

Qwik Rollup / Vite plugin

Describe the bug

The current Cloudflare pages setup makes it hard to develop qwik-city with Cloudflare page functions. Cloudflare has D1, KV etc objects that should be accessible during the development mode but at the moment we should first build. The build drops the static files to dist folder which can then be accessed using Cloudflare pages. Ideally, we should be able to have the HMR and wrangler reload during local development.

Can we provide guidance on how to develop locally with Cloudflare and qwik-city vite? (https://developers.cloudflare.com/pages/platform/functions/local-development/)

export const useListLoader = routeLoader$(async (context: any) => {
  const ps = (context.env.get("cloudflaredb") as any)?.prepare(
    "SELECT * FROM users"
  );
  if (ps) {
    const users = await ps.first();
    return {
      users,
    };
  } else {
    console.log("No access to D1", context.env.get("cloudflaredb"));
  }

  return {
    users: [],
  };
});

Reproduction

https://stackblitz.com/edit/qwik-starter-joopk8?file=src%2Froutes%2Findex.tsx

Steps to reproduce

No response

System Info

System:
    OS: macOS 13.0
    CPU: (8) arm64 Apple M1 Pro
    Memory: 279.02 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.15.0 - ~/.volta/tools/image/node/18.15.0/bin/node
    Yarn: 1.22.19 - ~/.volta/tools/image/yarn/1.22.19/bin/yarn
    npm: 9.5.0 - ~/.volta/tools/image/node/18.15.0/bin/npm
  Browsers:
    Chrome: 111.0.5563.64
    Safari: 16.1
  npmPackages:
    @builder.io/qwik: 0.20.1 => 0.20.1
    @builder.io/qwik-city: 0.5.2 => 0.5.2
    undici: 5.20.0 => 5.20.0
    vite: 4.1.4 => 4.1.4

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    In Progress (STAGE 2)

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions