@sveltejs/adapter-cloudflare
Advanced tools
Comparing version 3.0.2 to 4.0.0
@@ -8,2 +8,14 @@ import { Adapter } from '@sveltejs/kit'; | ||
/** | ||
* Whether to render a plaintext 404.html page, or a rendered SPA fallback page. This page will | ||
* only be served when a request that matches an entry in `routes.exclude` fails to match an asset. | ||
* | ||
* Most of the time `plaintext` is sufficient, but if you are using `routes.exclude` to manually | ||
* exclude a set of prerendered pages without exceeding the 100 route limit, you may wish to | ||
* use `spa` instead to avoid showing an unstyled 404 page to users. | ||
* | ||
* @default 'plaintext' | ||
*/ | ||
fallback?: 'plaintext' | 'spa'; | ||
/** | ||
* Customize the automatically-generated `_routes.json` file | ||
@@ -10,0 +22,0 @@ * https://developers.cloudflare.com/pages/platform/functions/routing/#create-a-_routesjson-file |
11
index.js
@@ -17,6 +17,13 @@ import { writeFileSync } from 'node:fs'; | ||
builder.rimraf(tmp); | ||
builder.mkdirp(dest); | ||
builder.mkdirp(tmp); | ||
// generate 404.html first which can then be overridden by prerendering, if the user defined such a page | ||
await builder.generateFallback(path.join(dest, '404.html')); | ||
// generate plaintext 404.html first which can then be overridden by prerendering, if the user defined such a page | ||
const fallback = path.join(dest, '404.html'); | ||
if (options.fallback === 'spa') { | ||
await builder.generateFallback(fallback); | ||
} else { | ||
writeFileSync(fallback, 'Not Found'); | ||
} | ||
@@ -23,0 +30,0 @@ const dest_dir = `${dest}${builder.config.kit.paths.base}`; |
{ | ||
"name": "@sveltejs/adapter-cloudflare", | ||
"version": "3.0.2", | ||
"version": "4.0.0", | ||
"description": "Adapter for building SvelteKit applications on Cloudflare Pages with Workers integration", | ||
@@ -36,3 +36,3 @@ "repository": { | ||
"typescript": "^5.3.3", | ||
"@sveltejs/kit": "^2.3.2" | ||
"@sveltejs/kit": "^2.3.3" | ||
}, | ||
@@ -39,0 +39,0 @@ "peerDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12281
280