@cloudflare/vite-plugin 2.0.0-beta.v.9 → 2.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -34
- package/dist/cf-vite.mjs +0 -6
- package/dist/index.d.mts +10 -8
- package/dist/index.mjs +21253 -20770
- package/dist/{package--jIwlDD7.mjs → package-DdTPrOmV.mjs} +2 -2
- package/dist/workers/asset-worker/index.js +21 -11
- package/dist/workers/runner-worker/module-runner-legacy.js +1 -1
- package/dist/workers/runner-worker/module-runner.js +1 -1
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -18,40 +18,6 @@ export default defineConfig({
|
|
|
18
18
|
|
|
19
19
|
Full documentation can be found [here](https://developers.cloudflare.com/workers/vite-plugin/).
|
|
20
20
|
|
|
21
|
-
## Programmatic configuration
|
|
22
|
-
|
|
23
|
-
The `config` option accepts a customizer with the signature
|
|
24
|
-
`(loadedConfig: ParsedInputConfigWithWorker) => ParsedInputConfigWithWorker`. It receives the parsed
|
|
25
|
-
`cloudflare.config.ts` configuration, or a default Worker configuration when no
|
|
26
|
-
file exists, and can customize account settings, Containers, and the entry Worker.
|
|
27
|
-
The loaded and returned configurations must include a Worker, even for assets-only projects.
|
|
28
|
-
|
|
29
|
-
Return a new configuration object, spreading any existing fields you want to
|
|
30
|
-
preserve. Nested objects and arrays are replaced rather than merged:
|
|
31
|
-
|
|
32
|
-
```ts
|
|
33
|
-
import { cloudflare } from "@cloudflare/vite-plugin";
|
|
34
|
-
|
|
35
|
-
cloudflare({
|
|
36
|
-
config(loadedConfig) {
|
|
37
|
-
return {
|
|
38
|
-
...loadedConfig,
|
|
39
|
-
worker: {
|
|
40
|
-
...loadedConfig.worker,
|
|
41
|
-
env: {
|
|
42
|
-
...loadedConfig.worker.env,
|
|
43
|
-
FRAMEWORK_NAME: { type: "text", value: "my-framework" },
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
The customized configuration is recorded in the build output. Preview and
|
|
52
|
-
deployment from that output use the recorded configuration. Generated types
|
|
53
|
-
continue to describe `cloudflare.config.ts`.
|
|
54
|
-
|
|
55
21
|
## Features
|
|
56
22
|
|
|
57
23
|
- Uses the Vite [Environment API](https://vite.dev/guide/api-environment) to integrate Vite with the Workers runtime
|
package/dist/cf-vite.mjs
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { parseArgs } from "node:util";
|
|
2
2
|
import { createBuilder, createServer } from "vite";
|
|
3
3
|
|
|
4
|
-
//#region src/build-output-env.ts
|
|
5
|
-
/** Internal caller name set by the `cf-vite` delegate. */
|
|
6
|
-
const CLI_DISPLAY_NAME_ENV_VAR = "CLOUDFLARE_VITE_CLI_DISPLAY_NAME";
|
|
7
|
-
|
|
8
|
-
//#endregion
|
|
9
4
|
//#region src/cf-vite.ts
|
|
10
5
|
/**
|
|
11
6
|
* `cf-vite` delegate binary entry point for `@cloudflare/vite-plugin`.
|
|
@@ -89,7 +84,6 @@ function parseBuildArgs(argv) {
|
|
|
89
84
|
return out;
|
|
90
85
|
}
|
|
91
86
|
async function main() {
|
|
92
|
-
process.env[CLI_DISPLAY_NAME_ENV_VAR] = "cf";
|
|
93
87
|
const verb = process.argv[2];
|
|
94
88
|
const userArgv = process.argv.slice(3);
|
|
95
89
|
if (verb === "dev") return runDev(userArgv);
|
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import * as vite from "vite";
|
|
2
|
-
import {
|
|
2
|
+
import { ParsedCloudflareConfig, ParsedWorkerConfig } from "@cloudflare/config";
|
|
3
3
|
import { CompatDate } from "@cloudflare/workers-utils";
|
|
4
4
|
|
|
5
5
|
//#region src/plugin-config.d.ts
|
|
6
6
|
|
|
7
7
|
/** Parsed configuration with the entry Worker required by the Vite plugin. */
|
|
8
|
-
type
|
|
9
|
-
worker:
|
|
8
|
+
type CloudflareConfig = Omit<ParsedCloudflareConfig, "worker"> & {
|
|
9
|
+
worker: ParsedWorkerConfig;
|
|
10
10
|
};
|
|
11
|
+
/** Parsed Worker configuration, as used by auxiliary and prerender Worker `config`. */
|
|
12
|
+
type WorkerConfig = CloudflareConfig["worker"];
|
|
11
13
|
type PersistState = boolean | {
|
|
12
14
|
path: string;
|
|
13
15
|
};
|
|
@@ -67,9 +69,9 @@ interface Experimental {
|
|
|
67
69
|
/** Experimental support for handling the _headers and _redirects files during Vite dev mode. */
|
|
68
70
|
headersAndRedirectsDevModeSupport?: boolean;
|
|
69
71
|
}
|
|
70
|
-
type WorkerConfigProvider =
|
|
71
|
-
entryWorkerConfig:
|
|
72
|
-
}) =>
|
|
72
|
+
type WorkerConfigProvider = WorkerConfig | ((options: {
|
|
73
|
+
entryWorkerConfig: WorkerConfig;
|
|
74
|
+
}) => WorkerConfig);
|
|
73
75
|
interface PluginConfig extends EntryWorkerOptions {
|
|
74
76
|
/**
|
|
75
77
|
* Customize the loaded configuration before development or building.
|
|
@@ -77,7 +79,7 @@ interface PluginConfig extends EntryWorkerOptions {
|
|
|
77
79
|
* Return a new configuration object including an entry Worker, copying any settings to preserve.
|
|
78
80
|
* Preview uses the configuration recorded in the build output.
|
|
79
81
|
*/
|
|
80
|
-
config?: (loadedConfig:
|
|
82
|
+
config?: (loadedConfig: CloudflareConfig) => CloudflareConfig;
|
|
81
83
|
auxiliaryWorkers?: AuxiliaryWorkerOptions[];
|
|
82
84
|
/** Configuration for a dedicated prerender Worker. */
|
|
83
85
|
prerenderWorker?: PrerenderWorkerOptions;
|
|
@@ -120,4 +122,4 @@ declare function getLocalWorkerdCompatibilityDate(_options?: {
|
|
|
120
122
|
*/
|
|
121
123
|
declare function cloudflare(pluginConfig?: PluginConfig): vite.Plugin[];
|
|
122
124
|
//#endregion
|
|
123
|
-
export { type
|
|
125
|
+
export { type CloudflareConfig, type PluginConfig, type WorkerConfig, cloudflare, getLocalWorkerdCompatibilityDate };
|