@cloudflare/vite-plugin 1.55.0 → 1.57.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/dist/cf-vite.mjs CHANGED
@@ -7,6 +7,7 @@ import { createBuilder, createServer } from "vite";
7
7
  * delegate uses to force the experimental Build Output Specification on by default.
8
8
  */
9
9
  const FORCE_BUILD_OUTPUT_ENV_VAR = "CLOUDFLARE_VITE_FORCE_BUILD_OUTPUT";
10
+ const PREVIEW_BUILD_ENV_VAR = "CLOUDFLARE_VITE_PREVIEW_BUILD";
10
11
 
11
12
  //#endregion
12
13
  //#region src/cf-vite.ts
@@ -38,7 +39,7 @@ const FORCE_BUILD_OUTPUT_ENV_VAR = "CLOUDFLARE_VITE_FORCE_BUILD_OUTPUT";
38
39
  * `build` runs Vite's full multi-environment app build via
39
40
  * `createBuilder().buildApp()` (NOT the legacy single-environment
40
41
  * `build()` helper, which would skip the plugin's worker builds). It
41
- * accepts only `--mode` (the other shared flags don't apply to a build).
42
+ * accepts `--mode` and the internal `--preview` build context flag.
42
43
  *
43
44
  * Exit codes: 0 graceful, 2 unknown verb / parse error, 130 SIGINT,
44
45
  * 143 SIGTERM.
@@ -84,7 +85,10 @@ function parseBuildArgs(argv) {
84
85
  try {
85
86
  parsed = parseArgs({
86
87
  args: argv,
87
- options: { mode: { type: "string" } },
88
+ options: {
89
+ mode: { type: "string" },
90
+ preview: { type: "boolean" }
91
+ },
88
92
  strict: true,
89
93
  allowPositionals: false
90
94
  });
@@ -93,6 +97,7 @@ function parseBuildArgs(argv) {
93
97
  }
94
98
  const out = {};
95
99
  if (parsed.values.mode !== void 0) out.mode = parsed.values.mode;
100
+ if (parsed.values.preview !== void 0) out.preview = parsed.values.preview;
96
101
  return out;
97
102
  }
98
103
  async function main() {
@@ -153,6 +158,7 @@ async function runBuild(userArgv) {
153
158
  }
154
159
  throw err;
155
160
  }
161
+ process.env[PREVIEW_BUILD_ENV_VAR] = args.preview === true ? "true" : "false";
156
162
  const inlineConfig = {};
157
163
  if (args.mode !== void 0) inlineConfig.mode = args.mode;
158
164
  await (await createBuilder(inlineConfig)).buildApp();