Skip to content

Commit

Permalink
fix the generation of invalid/incorrect scripts for Next.js applicati…
Browse files Browse the repository at this point in the history
…ons (#4200)
  • Loading branch information
dario-piotrowicz authored Oct 23, 2023
1 parent b5e62b9 commit 773e2a8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/tasty-teachers-lick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-cloudflare": patch
---

fix the generation of invalid/incorrect scripts for Next.js applications
20 changes: 14 additions & 6 deletions packages/create-cloudflare/src/frameworks/next/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,20 @@ const config: FrameworkConfig = {
generate,
configure,
displayName: "Next",
getPackageScripts: async () => ({
"pages:build": `${dlx} @cloudflare/next-on-pages@1`,
"pages:deploy": `${npm} run pages:build && wrangler pages deploy .vercel/output/static`,
"pages:watch": `${npx} @cloudflare/next-on-pages@1 --watch`,
"pages:dev": `${npx} wrangler pages dev .vercel/output/static ${await compatDateFlag()} --compatibility-flag=nodejs_compat`,
}),
getPackageScripts: async () => {
const isNpmOrBun = ["npm", "bun"].includes(npm);
const nextOnPagesScope = isNpmOrBun ? "@cloudflare/" : "";
const nextOnPagesCommand = `${nextOnPagesScope}next-on-pages`;
const pmCommand = isNpmOrBun ? npx : npm;
return {
"pages:build": `${pmCommand} ${nextOnPagesCommand}`,
"pages:deploy": `${
npm === "npm" ? "npm run" : pmCommand
} pages:build && wrangler pages deploy .vercel/output/static`,
"pages:watch": `${pmCommand} ${nextOnPagesCommand} --watch`,
"pages:dev": `${pmCommand} wrangler pages dev .vercel/output/static ${await compatDateFlag()} --compatibility-flag=nodejs_compat`,
};
},
testFlags: [
"--typescript",
"--no-install",
Expand Down

0 comments on commit 773e2a8

Please sign in to comment.