#How to trigger SSG build when using Cloudflare Adapter
16 messages · Page 1 of 1 (latest)
I think this is the option:
adapters/cloudflare-pages/vite.config.ts
plugins: [cloudflarePagesAdapter({
ssg: {
include: ['/*'],
origin:
(process.env.CF_PAGES_BRANCH !== 'main' ? process.env.CF_PAGES_URL : null) ??
'https://yoursite.com',
}
})],
thanks for the response, now do i have to also re-declare every ssg routes also in the staticPath property of the adapter options? like so?
plugins: [cloudflarePagesAdapter(
{
staticPaths:[
'/demo/flower'
],
ssg: {
include: ['/demo/flower'],
origin:
(process.env.CF_PAGES_BRANCH !== 'main' ? process.env.CF_PAGES_URL : null) ??
'qwikapp-cyz.pages.dev',
}
}
also, since it's my first time experimenting with cloudflare pages, it has come to my understanding static files are delivered from their CDN not from their workers, how can i check if this is indeed the case for the indicated ssg routes?
when running npm run deploy i get this error after selecting the project
✘ [ERROR] Could not resolve "..serverentry.cloudflare-pages"
_worker.js:1:22:
1 │ ...{ fetch } from "..\server\entry.cloudflare-pages"; export defaul...
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can mark the path "..serverentry.cloudflare-pages" as external to exclude it from the bundle, which will remove this error.
✘ [ERROR] Build failed with 1 error:
_worker.js:1:22: ERROR: Could not resolve "..serverentry.cloudflare-pages"
I think so?
unfortuantelly I don't know the solution :/
maybe you didn't set it up correctly? entry.cloudflare-pages.tsx should have been created for you https://github.com/BuilderIO/qwik/blob/b122dd4bd0ac5d199d782304273c4728fd37bc5d/packages/docs/src/routes/docs/deployments/cloudflare-pages/index.mdx?plain=1#L31
as I can see this is a problem only on windows os, maybe create a gh issue and as workaround try wsl?
thanks for help, i can seem to get npm run deploy to work even in an wsl enviroment. when running under wsl i keep getting asked to give a new project name and it doesn't let me choose an existing project. on windows it does let me choose an existing project but errors after upload
i made an issue for the error under the windows enviroment, i'm not sure i am not at fault for wsl workaround not working, i tried making a wrangler.toml file with all the config but with no success
remember that npm run build is required before npm run deploy
I added this to scripts:
"preview.wrangler": "qwik build && wrangler pages dev ./dist",
and it works for me
thanks for your input on this issue @stark jackal you've been verry helpful to me
@tidal raft have you been successful in this? I would also like to have all my product routes served as static files from cloudflare without buring workers CPU cycles.