mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
add cloudflare workers support for all frontends (#366)
This commit is contained in:
51
apps/cli/templates/deploy/web/nuxt/wrangler.jsonc.hbs
Normal file
51
apps/cli/templates/deploy/web/nuxt/wrangler.jsonc.hbs
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* For more details on how to configure Wrangler, refer to:
|
||||
* https://developers.cloudflare.com/workers/wrangler/configuration/
|
||||
*/
|
||||
{
|
||||
"$schema": "../../node_modules/wrangler/config-schema.json",
|
||||
"name": "{{projectName}}",
|
||||
"main": "./.output/server/index.mjs",
|
||||
"compatibility_date": "2025-07-01",
|
||||
"assets": {
|
||||
"binding": "ASSETS",
|
||||
"directory": "./.output/public/"
|
||||
},
|
||||
"observability": {
|
||||
"enabled": true
|
||||
}
|
||||
/**
|
||||
* Smart Placement
|
||||
* Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement
|
||||
*/
|
||||
// "placement": { "mode": "smart" },
|
||||
|
||||
/**
|
||||
* Bindings
|
||||
* Bindings allow your Worker to interact with resources on the Cloudflare Developer Platform, including
|
||||
* databases, object storage, AI inference, real-time communication and more.
|
||||
* https://developers.cloudflare.com/workers/runtime-apis/bindings/
|
||||
*/
|
||||
|
||||
/**
|
||||
* Environment Variables
|
||||
* https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
|
||||
*/
|
||||
// "vars": { "MY_VARIABLE": "production_value" },
|
||||
/**
|
||||
* Note: Use secrets to store sensitive data.
|
||||
* https://developers.cloudflare.com/workers/configuration/secrets/
|
||||
*/
|
||||
|
||||
/**
|
||||
* Static Assets
|
||||
* https://developers.cloudflare.com/workers/static-assets/binding/
|
||||
*/
|
||||
// "assets": { "directory": "./public/", "binding": "ASSETS" },
|
||||
|
||||
/**
|
||||
* Service Bindings (communicate between multiple Workers)
|
||||
* https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
|
||||
*/
|
||||
// "services": [{ "binding": "MY_SERVICE", "service": "my-service" }]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { defineCloudflareConfig } from "@opennextjs/cloudflare/config";
|
||||
// import r2IncrementalCache from "@opennextjs/cloudflare/overrides/incremental-cache/r2-incremental-cache";
|
||||
|
||||
export default defineCloudflareConfig({
|
||||
// incrementalCache: r2IncrementalCache,
|
||||
});
|
||||
22
apps/cli/templates/deploy/web/react/next/wrangler.jsonc.hbs
Normal file
22
apps/cli/templates/deploy/web/react/next/wrangler.jsonc.hbs
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"$schema": "../../node_modules/wrangler/config-schema.json",
|
||||
"main": ".open-next/worker.js",
|
||||
"name": "{{projectName}}",
|
||||
"compatibility_date": "2025-07-05",
|
||||
"compatibility_flags": ["nodejs_compat", "global_fetch_strictly_public"],
|
||||
"assets": {
|
||||
"directory": ".open-next/assets",
|
||||
"binding": "ASSETS"
|
||||
},
|
||||
// "r2_buckets": [
|
||||
// // Use R2 incremental cache
|
||||
// // See https://opennext.js.org/cloudflare/caching
|
||||
// {
|
||||
// "binding": "NEXT_INC_CACHE_R2_BUCKET",
|
||||
// // Create the bucket before deploying
|
||||
// // You can change the bucket name if you want
|
||||
// // See https://developers.cloudflare.com/workers/wrangler/commands/#r2-bucket-create
|
||||
// "bucket_name": "cache"
|
||||
// }
|
||||
// ]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"$schema": "../../node_modules/wrangler/config-schema.json",
|
||||
"name": "{{projectName}}",
|
||||
"compatibility_date": "2025-04-03",
|
||||
"assets": {
|
||||
"not_found_handling": "single-page-application"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"$schema": "../../node_modules/wrangler/config-schema.json",
|
||||
"name": "{{projectName}}",
|
||||
"compatibility_date": "2025-04-03",
|
||||
"assets": {
|
||||
"not_found_handling": "single-page-application"
|
||||
}
|
||||
}
|
||||
8
apps/cli/templates/deploy/web/solid/wrangler.jsonc.hbs
Normal file
8
apps/cli/templates/deploy/web/solid/wrangler.jsonc.hbs
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"$schema": "../../node_modules/wrangler/config-schema.json",
|
||||
"name": "{{projectName}}",
|
||||
"compatibility_date": "2025-04-03",
|
||||
"assets": {
|
||||
"not_found_handling": "single-page-application"
|
||||
}
|
||||
}
|
||||
51
apps/cli/templates/deploy/web/svelte/wrangler.jsonc.hbs
Normal file
51
apps/cli/templates/deploy/web/svelte/wrangler.jsonc.hbs
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* For more details on how to configure Wrangler, refer to:
|
||||
* https://developers.cloudflare.com/workers/wrangler/configuration/
|
||||
*/
|
||||
{
|
||||
"$schema": "../../node_modules/wrangler/config-schema.json",
|
||||
"name": "{{projectName}}",
|
||||
"main": ".svelte-kit/cloudflare/_worker.js",
|
||||
"compatibility_date": "2025-07-05",
|
||||
"assets": {
|
||||
"binding": "ASSETS",
|
||||
"directory": ".svelte-kit/cloudflare"
|
||||
},
|
||||
"observability": {
|
||||
"enabled": true
|
||||
}
|
||||
/**
|
||||
* Smart Placement
|
||||
* Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement
|
||||
*/
|
||||
// "placement": { "mode": "smart" },
|
||||
|
||||
/**
|
||||
* Bindings
|
||||
* Bindings allow your Worker to interact with resources on the Cloudflare Developer Platform, including
|
||||
* databases, object storage, AI inference, real-time communication and more.
|
||||
* https://developers.cloudflare.com/workers/runtime-apis/bindings/
|
||||
*/
|
||||
|
||||
/**
|
||||
* Environment Variables
|
||||
* https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
|
||||
*/
|
||||
// "vars": { "MY_VARIABLE": "production_value" },
|
||||
/**
|
||||
* Note: Use secrets to store sensitive data.
|
||||
* https://developers.cloudflare.com/workers/configuration/secrets/
|
||||
*/
|
||||
|
||||
/**
|
||||
* Static Assets
|
||||
* https://developers.cloudflare.com/workers/static-assets/binding/
|
||||
*/
|
||||
// "assets": { "directory": "./public/", "binding": "ASSETS" },
|
||||
|
||||
/**
|
||||
* Service Bindings (communicate between multiple Workers)
|
||||
* https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
|
||||
*/
|
||||
// "services": [{ "binding": "MY_SERVICE", "service": "my-service" }]
|
||||
}
|
||||
@@ -1,6 +1,3 @@
|
||||
{{#if (includes addons "pwa")}}
|
||||
import { VitePWA } from "vite-plugin-pwa";
|
||||
{{/if}}
|
||||
import { reactRouter } from "@react-router/dev/vite";
|
||||
import tailwindcss from "@tailwindcss/vite";
|
||||
import { defineConfig } from "vite";
|
||||
@@ -11,23 +8,5 @@ export default defineConfig({
|
||||
tailwindcss(),
|
||||
reactRouter(),
|
||||
tsconfigPaths(),
|
||||
{{#if (includes addons "pwa")}}
|
||||
VitePWA({
|
||||
registerType: "autoUpdate",
|
||||
manifest: {
|
||||
name: "{{projectName}}",
|
||||
short_name: "{{projectName}}",
|
||||
description: "{{projectName}} - PWA Application",
|
||||
theme_color: "#0c0c0c",
|
||||
},
|
||||
pwaAssets: {
|
||||
disabled: false,
|
||||
config: true,
|
||||
},
|
||||
devOptions: {
|
||||
enabled: true,
|
||||
},
|
||||
}),
|
||||
{{/if}}
|
||||
],
|
||||
});
|
||||
});
|
||||
@@ -1,8 +1,5 @@
|
||||
{{#if (includes addons "pwa")}}
|
||||
import { VitePWA } from "vite-plugin-pwa";
|
||||
{{/if}}
|
||||
import tailwindcss from "@tailwindcss/vite";
|
||||
import { TanStackRouterVite } from "@tanstack/router-plugin/vite";
|
||||
import { tanstackRouter } from "@tanstack/router-plugin/vite";
|
||||
import react from "@vitejs/plugin-react";
|
||||
import path from "node:path";
|
||||
import { defineConfig } from "vite";
|
||||
@@ -10,30 +7,12 @@ import { defineConfig } from "vite";
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
tailwindcss(),
|
||||
TanStackRouterVite({}),
|
||||
tanstackRouter({}),
|
||||
react(),
|
||||
{{#if (includes addons "pwa")}}
|
||||
VitePWA({
|
||||
registerType: "autoUpdate",
|
||||
manifest: {
|
||||
name: "{{projectName}}",
|
||||
short_name: "{{projectName}}",
|
||||
description: "{{projectName}} - PWA Application",
|
||||
theme_color: "#0c0c0c",
|
||||
},
|
||||
pwaAssets: {
|
||||
disabled: false,
|
||||
config: true,
|
||||
},
|
||||
devOptions: {
|
||||
enabled: true,
|
||||
},
|
||||
}),
|
||||
{{/if}}
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
"@": path.resolve(__dirname, "./src"),
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -17,14 +17,14 @@
|
||||
"@tanstack/react-start": "^1.121.0-alpha.27",
|
||||
"@tanstack/router-plugin": "^1.121.0",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"lucide-react": "^0.473.0",
|
||||
"clsx": "^2.1.1",
|
||||
"lucide-react": "^0.525.0",
|
||||
"next-themes": "^0.4.6",
|
||||
"react": "19.0.0",
|
||||
"react-dom": "19.0.0",
|
||||
"sonner": "^2.0.3",
|
||||
"tailwindcss": "^4.1.3",
|
||||
"tailwind-merge": "^2.6.0",
|
||||
"tailwind-merge": "^3.3.1",
|
||||
"tw-animate-css": "^1.2.5",
|
||||
"vite-tsconfig-paths": "^5.1.4",
|
||||
"zod": "^3.25.16"
|
||||
@@ -38,7 +38,7 @@
|
||||
"@vitejs/plugin-react": "^4.5.2",
|
||||
"jsdom": "^26.0.0",
|
||||
"typescript": "^5.7.2",
|
||||
"vite": "^6.3.5",
|
||||
"web-vitals": "^4.2.4"
|
||||
"vite": "^7.0.2",
|
||||
"web-vitals": "^5.0.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,3 +50,8 @@ next-env.d.ts
|
||||
|
||||
# Other
|
||||
dev-dist
|
||||
|
||||
.wrangler
|
||||
.dev.vars*
|
||||
|
||||
.open-next
|
||||
|
||||
@@ -5,3 +5,6 @@ dist-ssr
|
||||
*.local
|
||||
.env
|
||||
.env.*
|
||||
|
||||
.wrangler
|
||||
.dev.vars*
|
||||
@@ -4,7 +4,7 @@
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite --port 3001",
|
||||
"build": "vite build && tsc",
|
||||
"build": "vite build",
|
||||
"serve": "vite preview",
|
||||
"test": "vitest run"
|
||||
},
|
||||
@@ -21,7 +21,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.7.2",
|
||||
"vite": "^6.0.11",
|
||||
"vite": "^7.0.2",
|
||||
"vite-plugin-solid": "^2.11.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import { routeTree } from "./routeTree.gen";
|
||||
import "./styles.css";
|
||||
{{#if (eq api "orpc")}}
|
||||
import { QueryClientProvider } from "@tanstack/solid-query";
|
||||
import { queryClient } from "./utils/orpc";
|
||||
import { orpc, queryClient } from "./utils/orpc";
|
||||
{{/if}}
|
||||
|
||||
const router = createRouter({
|
||||
@@ -12,6 +12,9 @@ const router = createRouter({
|
||||
defaultPreload: "intent",
|
||||
scrollRestoration: true,
|
||||
defaultPreloadStaleTime: 0,
|
||||
{{#if (eq api "orpc")}}
|
||||
context: { orpc, queryClient },
|
||||
{{/if}}
|
||||
});
|
||||
|
||||
declare module "@tanstack/solid-router" {
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
import { defineConfig } from "vite";
|
||||
import { TanStackRouterVite } from "@tanstack/router-plugin/vite";
|
||||
import solidPlugin from "vite-plugin-solid";
|
||||
import tailwindcss from "@tailwindcss/vite";
|
||||
import path from "node:path";
|
||||
{{#if (includes addons "pwa")}}
|
||||
import { VitePWA } from "vite-plugin-pwa";
|
||||
{{/if}}
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
TanStackRouterVite({ target: "solid", autoCodeSplitting: true }),
|
||||
solidPlugin(),
|
||||
tailwindcss(),
|
||||
{{#if (includes addons "pwa")}}
|
||||
VitePWA({
|
||||
registerType: "autoUpdate",
|
||||
manifest: {
|
||||
name: "{{projectName}}",
|
||||
short_name: "{{projectName}}",
|
||||
description: "{{projectName}} - PWA Application",
|
||||
theme_color: "#0c0c0c",
|
||||
},
|
||||
pwaAssets: {
|
||||
disabled: false,
|
||||
config: true,
|
||||
},
|
||||
devOptions: {
|
||||
enabled: true,
|
||||
},
|
||||
}),
|
||||
{{/if}}
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
"@": path.resolve(__dirname, "./src"),
|
||||
},
|
||||
},
|
||||
});
|
||||
18
apps/cli/templates/frontend/solid/vite.config.ts.hbs
Normal file
18
apps/cli/templates/frontend/solid/vite.config.ts.hbs
Normal file
@@ -0,0 +1,18 @@
|
||||
import { defineConfig } from "vite";
|
||||
import { tanstackRouter } from "@tanstack/router-plugin/vite";
|
||||
import solidPlugin from "vite-plugin-solid";
|
||||
import tailwindcss from "@tailwindcss/vite";
|
||||
import path from "node:path";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
tanstackRouter({ target: "solid", autoCodeSplitting: true }),
|
||||
solidPlugin(),
|
||||
tailwindcss(),
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
"@": path.resolve(__dirname, "./src"),
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -21,7 +21,7 @@
|
||||
"tailwindcss": "^4.1.4",
|
||||
"typescript": "^5.8.3",
|
||||
"@tanstack/svelte-query-devtools": "^5.74.6",
|
||||
"vite": "^6.3.3"
|
||||
"vite": "^7.0.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tanstack/svelte-form": "^1.7.0",
|
||||
|
||||
Reference in New Issue
Block a user