mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
docs: update cloudflare imports
This commit is contained in:
@@ -12,7 +12,7 @@ export function devFsVitePlugin({
|
|||||||
}: {
|
}: {
|
||||||
verbose?: boolean;
|
verbose?: boolean;
|
||||||
configFile?: string;
|
configFile?: string;
|
||||||
}): Plugin {
|
} = {}): any {
|
||||||
let isDev = false;
|
let isDev = false;
|
||||||
let projectRoot = "";
|
let projectRoot = "";
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ if (typeof globalThis !== 'undefined') {
|
|||||||
return polyfill + code;
|
return polyfill + code;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
} satisfies Plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write function that uses the dev-fs polyfill injected by our Vite plugin
|
// Write function that uses the dev-fs polyfill injected by our Vite plugin
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const schema = s.partialObject({
|
|||||||
metadata: s.string({ enum: ["copyright", "keep", "none"] }),
|
metadata: s.string({ enum: ["copyright", "keep", "none"] }),
|
||||||
quality: s.number({ minimum: 1, maximum: 100 }),
|
quality: s.number({ minimum: 1, maximum: 100 }),
|
||||||
});
|
});
|
||||||
type ImageOptimizationSchema = s.Static<typeof schema>;
|
export type CloudflareImageOptimizationSchema = s.Static<typeof schema>;
|
||||||
|
|
||||||
export type CloudflareImageOptimizationOptions = {
|
export type CloudflareImageOptimizationOptions = {
|
||||||
/**
|
/**
|
||||||
@@ -38,12 +38,12 @@ export type CloudflareImageOptimizationOptions = {
|
|||||||
* The default options to use
|
* The default options to use
|
||||||
* @default {}
|
* @default {}
|
||||||
*/
|
*/
|
||||||
defaultOptions?: ImageOptimizationSchema;
|
defaultOptions?: CloudflareImageOptimizationSchema;
|
||||||
/**
|
/**
|
||||||
* The fixed options to use
|
* The fixed options to use
|
||||||
* @default {}
|
* @default {}
|
||||||
*/
|
*/
|
||||||
fixedOptions?: ImageOptimizationSchema;
|
fixedOptions?: CloudflareImageOptimizationSchema;
|
||||||
/**
|
/**
|
||||||
* The cache control to use
|
* The cache control to use
|
||||||
* @default public, max-age=31536000, immutable
|
* @default public, max-age=31536000, immutable
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
export {
|
export {
|
||||||
cloudflareImageOptimization,
|
cloudflareImageOptimization,
|
||||||
|
type CloudflareImageOptimizationSchema,
|
||||||
type CloudflareImageOptimizationOptions,
|
type CloudflareImageOptimizationOptions,
|
||||||
} from "./cloudflare/image-optimization.plugin";
|
} from "./cloudflare/image-optimization.plugin";
|
||||||
export { showRoutes, type ShowRoutesOptions } from "./dev/show-routes.plugin";
|
export { showRoutes, type ShowRoutesOptions } from "./dev/show-routes.plugin";
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ The [Cloudflare Vite Plugin](https://developers.cloudflare.com/workers/vite-plug
|
|||||||
To fix this, bknd exports a Vite plugin that provides filesystem access during development. You can use it by adding the following to your `vite.config.ts` file:
|
To fix this, bknd exports a Vite plugin that provides filesystem access during development. You can use it by adding the following to your `vite.config.ts` file:
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { devFsVitePlugin } from "bknd/adapter/cloudflare/vite";
|
import { devFsVitePlugin } from "bknd/adapter/cloudflare";
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [devFsVitePlugin()], // [!code highlight]
|
plugins: [devFsVitePlugin()], // [!code highlight]
|
||||||
@@ -173,7 +173,7 @@ export default defineConfig({
|
|||||||
Now to use this polyfill, you can use the `devFsWrite` function to write files to the filesystem.
|
Now to use this polyfill, you can use the `devFsWrite` function to write files to the filesystem.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { devFsWrite } from "bknd/adapter/cloudflare/vite"; // [!code highlight]
|
import { devFsWrite } from "bknd/adapter/cloudflare"; // [!code highlight]
|
||||||
import { syncTypes } from "bknd/plugins";
|
import { syncTypes } from "bknd/plugins";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|||||||
@@ -1,21 +1,7 @@
|
|||||||
import type { CloudflareBkndConfig } from "bknd/adapter/cloudflare";
|
import type { CloudflareBkndConfig } from "bknd/adapter/cloudflare";
|
||||||
import { syncTypes } from "bknd/plugins";
|
|
||||||
import { writeFile } from "node:fs/promises";
|
|
||||||
|
|
||||||
const isDev = import.meta.env && !import.meta.env.PROD;
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
d1: {
|
d1: {
|
||||||
session: true,
|
session: true,
|
||||||
},
|
},
|
||||||
options: {
|
|
||||||
plugins: [
|
|
||||||
syncTypes({
|
|
||||||
enabled: isDev,
|
|
||||||
write: async (et) => {
|
|
||||||
await writeFile("bknd-types.d.ts", et.toString());
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
} satisfies CloudflareBkndConfig;
|
} satisfies CloudflareBkndConfig;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"$schema": "node_modules/wrangler/config-schema.json",
|
"$schema": "node_modules/wrangler/config-schema.json",
|
||||||
"name": "bknd-cf-worker-example",
|
"name": "bknd-cf-worker-example",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"compatibility_date": "2025-02-04",
|
"compatibility_date": "2025-08-03",
|
||||||
"compatibility_flags": ["nodejs_compat"],
|
"compatibility_flags": ["nodejs_compat"],
|
||||||
"workers_dev": true,
|
"workers_dev": true,
|
||||||
"minify": true,
|
"minify": true,
|
||||||
|
|||||||
Reference in New Issue
Block a user