@cloudflare/vite-plugin 0.0.0-ea3e16a89 → 0.0.0-f1ef4f10e

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.
Files changed (3) hide show
  1. package/README.md +0 -7
  2. package/dist/index.js +17 -49
  3. package/package.json +4 -4
package/README.md CHANGED
@@ -466,13 +466,6 @@ The value of `MY_VAR` will therefore be `'Production var'`.
466
466
  If you run `vite build --mode staging` then the 'staging' Vite mode will be used and the 'staging' Cloudflare environment will be selected.
467
467
  The value of `MY_VAR` will therefore be `'Staging var'`.
468
468
 
469
- ## Secrets
470
-
471
- Secrets can be provided to your Worker in local development using a [`.dev.vars`](https://developers.cloudflare.com/workers/configuration/secrets/#local-development-with-secrets) file. If you are using [Cloudflare Environments](#cloudflare-environments) then the relevant `.dev.vars` file will be selected. For example, `CLOUDFLARE_ENV=staging vite dev` will load `.dev.vars.staging` if it exists and fall back to `.dev.vars`.
472
-
473
- > [!NOTE]
474
- > The `vite build` command copies the relevant `.dev.vars[.env-name]` file to the output directory. This is only used when running `vite preview` and is not deployed with your Worker.
475
-
476
469
  ## Migrating from `wrangler dev`
477
470
 
478
471
  Migrating from `wrangler dev` is a simple process and you can follow the instructions in the [Quick start](#quick-start) to get started.
package/dist/index.js CHANGED
@@ -1637,13 +1637,10 @@ function getDevMiniflareOptions(resolvedPluginConfig, viteDevServer) {
1637
1637
  ];
1638
1638
  const userWorkers = resolvedPluginConfig.type === "workers" ? Object.entries(resolvedPluginConfig.workers).map(
1639
1639
  ([environmentName, workerConfig]) => {
1640
- const miniflareWorkerOptions = unstable_getMiniflareWorkerOptions(
1641
- {
1642
- ...workerConfig,
1643
- assets: void 0
1644
- },
1645
- resolvedPluginConfig.cloudflareEnv
1646
- );
1640
+ const miniflareWorkerOptions = unstable_getMiniflareWorkerOptions({
1641
+ ...workerConfig,
1642
+ assets: void 0
1643
+ });
1647
1644
  const { ratelimits, ...workerOptions } = miniflareWorkerOptions.workerOptions;
1648
1645
  return {
1649
1646
  ...workerOptions,
@@ -2067,21 +2064,20 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
2067
2064
  const configPaths = /* @__PURE__ */ new Set();
2068
2065
  const persistState = pluginConfig.persistState ?? true;
2069
2066
  const root = userConfig.root ? path5.resolve(userConfig.root) : process.cwd();
2070
- const { CLOUDFLARE_ENV: cloudflareEnv } = vite5.loadEnv(
2071
- viteEnv.mode,
2072
- root,
2073
- /* prefixes */
2074
- ""
2075
- );
2067
+ const { CLOUDFLARE_ENV } = vite5.loadEnv(viteEnv.mode, root, "");
2076
2068
  const configPath = pluginConfig.configPath ? path5.resolve(root, pluginConfig.configPath) : findWranglerConfig(root);
2077
2069
  assert6(
2078
2070
  configPath,
2079
2071
  `Config not found. Have you created a wrangler.json(c) or wrangler.toml file?`
2080
2072
  );
2081
- const entryWorkerResolvedConfig = getWorkerConfig(configPath, cloudflareEnv, {
2082
- visitedConfigPaths: configPaths,
2083
- isEntryWorker: true
2084
- });
2073
+ const entryWorkerResolvedConfig = getWorkerConfig(
2074
+ configPath,
2075
+ CLOUDFLARE_ENV,
2076
+ {
2077
+ visitedConfigPaths: configPaths,
2078
+ isEntryWorker: true
2079
+ }
2080
+ );
2085
2081
  if (entryWorkerResolvedConfig.type === "assets-only") {
2086
2082
  return {
2087
2083
  type: "assets-only",
@@ -2090,8 +2086,7 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
2090
2086
  persistState,
2091
2087
  rawConfigs: {
2092
2088
  entryWorker: entryWorkerResolvedConfig
2093
- },
2094
- cloudflareEnv
2089
+ }
2095
2090
  };
2096
2091
  }
2097
2092
  const entryWorkerConfig = entryWorkerResolvedConfig.config;
@@ -2103,7 +2098,7 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
2103
2098
  for (const auxiliaryWorker of pluginConfig.auxiliaryWorkers ?? []) {
2104
2099
  const workerResolvedConfig = getWorkerConfig(
2105
2100
  path5.resolve(root, auxiliaryWorker.configPath),
2106
- cloudflareEnv,
2101
+ CLOUDFLARE_ENV,
2107
2102
  {
2108
2103
  visitedConfigPaths: configPaths
2109
2104
  }
@@ -2131,8 +2126,7 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
2131
2126
  rawConfigs: {
2132
2127
  entryWorker: entryWorkerResolvedConfig,
2133
2128
  auxiliaryWorkers: auxiliaryWorkersResolvedConfigs
2134
- },
2135
- cloudflareEnv
2129
+ }
2136
2130
  };
2137
2131
  }
2138
2132
 
@@ -2323,28 +2317,13 @@ function cloudflare2(pluginConfig = {}) {
2323
2317
  );
2324
2318
  }
2325
2319
  config = workerConfig;
2326
- if (workerConfig.configPath) {
2327
- const dotDevDotVarsContent = getDotDevDotVarsContent(
2328
- workerConfig.configPath,
2329
- resolvedPluginConfig.cloudflareEnv
2330
- );
2331
- if (dotDevDotVarsContent) {
2332
- this.emitFile({
2333
- type: "asset",
2334
- fileName: ".dev.vars",
2335
- source: dotDevDotVarsContent
2336
- });
2337
- }
2338
- }
2339
2320
  } else if (this.environment.name === "client") {
2340
2321
  const assetsOnlyConfig = resolvedPluginConfig.config;
2341
2322
  assetsOnlyConfig.assets.directory = ".";
2342
- const filesToAssetsIgnore = ["wrangler.json", ".dev.vars"];
2343
2323
  this.emitFile({
2344
2324
  type: "asset",
2345
2325
  fileName: ".assetsignore",
2346
- source: `${filesToAssetsIgnore.join("\n")}
2347
- `
2326
+ source: "wrangler.json"
2348
2327
  });
2349
2328
  config = assetsOnlyConfig;
2350
2329
  }
@@ -2424,17 +2403,6 @@ function cloudflare2(pluginConfig = {}) {
2424
2403
  }
2425
2404
  };
2426
2405
  }
2427
- function getDotDevDotVarsContent(configPath, cloudflareEnv) {
2428
- const configDir = path6.dirname(configPath);
2429
- const defaultDotDevDotVarsPath = `${configDir}/.dev.vars`;
2430
- const inputDotDevDotVarsPath = `${defaultDotDevDotVarsPath}${cloudflareEnv ? `.${cloudflareEnv}` : ""}`;
2431
- const targetPath = fs4.existsSync(inputDotDevDotVarsPath) ? inputDotDevDotVarsPath : fs4.existsSync(defaultDotDevDotVarsPath) ? defaultDotDevDotVarsPath : null;
2432
- if (targetPath) {
2433
- const dotDevDotVarsContent = fs4.readFileSync(targetPath);
2434
- return dotDevDotVarsContent;
2435
- }
2436
- return null;
2437
- }
2438
2406
  export {
2439
2407
  cloudflare2 as cloudflare
2440
2408
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudflare/vite-plugin",
3
- "version": "0.0.0-ea3e16a89",
3
+ "version": "0.0.0-f1ef4f10e",
4
4
  "description": "Cloudflare plugin for Vite",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -36,7 +36,7 @@
36
36
  "@hattip/adapter-node": "^0.0.49",
37
37
  "unenv": "npm:unenv-nightly@2.0.0-20241218-183400-5d6aec3",
38
38
  "ws": "^8.18.0",
39
- "miniflare": "0.0.0-ea3e16a89"
39
+ "miniflare": "0.0.0-f1ef4f10e"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@cloudflare/workers-types": "^4.20250121.0",
@@ -46,9 +46,9 @@
46
46
  "tsup": "8.3.0",
47
47
  "typescript": "^5.7.2",
48
48
  "vite": "^6.0.7",
49
- "@cloudflare/workers-shared": "0.0.0-ea3e16a89",
50
49
  "@cloudflare/workers-tsconfig": "0.0.0",
51
- "wrangler": "0.0.0-ea3e16a89"
50
+ "@cloudflare/workers-shared": "0.0.0-f1ef4f10e",
51
+ "wrangler": "0.0.0-f1ef4f10e"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "vite": "^6.0.7",