@cloudflare/vite-plugin 1.25.3 → 1.25.5

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/index.mjs CHANGED
@@ -2228,7 +2228,7 @@ function constructWranglerConfig(workerOrWorkers) {
2228
2228
  __name(constructWranglerConfig, "constructWranglerConfig");
2229
2229
 
2230
2230
  //#endregion
2231
- //#region ../workers-utils/dist/chunk-66S7A4CD.mjs
2231
+ //#region ../workers-utils/dist/chunk-NNMRVG4F.mjs
2232
2232
  var UserError = class extends Error {
2233
2233
  static {
2234
2234
  __name(this, "UserError");
@@ -4646,6 +4646,30 @@ function formatConfigSnippet(snippet, configPath, formatted = true) {
4646
4646
  else return formatted ? JSON.stringify(snippet, null, 2) : JSON.stringify(snippet);
4647
4647
  }
4648
4648
  __name(formatConfigSnippet, "formatConfigSnippet");
4649
+ function isDirectory(path2) {
4650
+ return fs.statSync(path2, { throwIfNoEntry: false })?.isDirectory() ?? false;
4651
+ }
4652
+ __name(isDirectory, "isDirectory");
4653
+ function removeDir(dirPath, { fireAndForget = false } = {}) {
4654
+ const result = fs.promises.rm(dirPath, {
4655
+ recursive: true,
4656
+ force: true,
4657
+ maxRetries: 5,
4658
+ retryDelay: 100
4659
+ });
4660
+ if (fireAndForget) result.catch(() => {});
4661
+ else return result;
4662
+ }
4663
+ __name(removeDir, "removeDir");
4664
+ function removeDirSync(dirPath) {
4665
+ fs.rmSync(dirPath, {
4666
+ recursive: true,
4667
+ force: true,
4668
+ maxRetries: 5,
4669
+ retryDelay: 100
4670
+ });
4671
+ }
4672
+ __name(removeDirSync, "removeDirSync");
4649
4673
 
4650
4674
  //#endregion
4651
4675
  //#region ../workers-utils/dist/index.mjs
@@ -5270,10 +5294,6 @@ __export(mod_esm_exports, { default: () => mod_esm_default });
5270
5294
  var import_mod_cjs = __toESM(require_mod_cjs3(), 1);
5271
5295
  __reExport(mod_esm_exports, __toESM(require_mod_cjs3(), 1));
5272
5296
  var mod_esm_default = import_mod_cjs.default;
5273
- function isDirectory(path4) {
5274
- return fs.statSync(path4, { throwIfNoEntry: false })?.isDirectory() ?? false;
5275
- }
5276
- __name(isDirectory, "isDirectory");
5277
5297
  function getGlobalWranglerConfigPath() {
5278
5298
  const configDir = mod_esm_default(".wrangler").config();
5279
5299
  const legacyConfigDir = path3.join(os.homedir(), ".wrangler");
@@ -26465,10 +26485,12 @@ const outputConfigPlugin = createPlugin("output-config", (ctx) => {
26465
26485
  });
26466
26486
  }
26467
26487
  } else if (this.environment.name === "client") {
26488
+ const filesToAssetsIgnore = ["wrangler.json", ".dev.vars"];
26489
+ const existingAssetsIgnoreContent = ctx.resolvedViteConfig.publicDir.length > 0 ? readAssetsIgnoreFile(nodePath.join(ctx.resolvedViteConfig.publicDir, ".assetsignore")) : "";
26468
26490
  this.emitFile({
26469
26491
  type: "asset",
26470
26492
  fileName: ".assetsignore",
26471
- source: `${["wrangler.json", ".dev.vars"].join("\n")}\n`
26493
+ source: `${existingAssetsIgnoreContent}${filesToAssetsIgnore.join("\n")}\n`
26472
26494
  });
26473
26495
  if (ctx.resolvedPluginConfig.type === "assets-only") {
26474
26496
  const inputAssetsOnlyConfig = ctx.resolvedPluginConfig.config;
@@ -26495,6 +26517,11 @@ const outputConfigPlugin = createPlugin("output-config", (ctx) => {
26495
26517
  }
26496
26518
  };
26497
26519
  });
26520
+ function readAssetsIgnoreFile(assetsIgnorePath) {
26521
+ const content = existsSync(assetsIgnorePath) ? readFileSync(assetsIgnorePath, "utf-8") : "";
26522
+ if (content.length === 0) return "";
26523
+ return content.at(-1) === "\n" ? content : `${content}\n`;
26524
+ }
26498
26525
  function getAssetsDirectory(workerOutputDirectory, resolvedViteConfig) {
26499
26526
  const clientOutputDirectory = resolvedViteConfig.environments.client?.build.outDir;
26500
26527
  assert(clientOutputDirectory, "Unexpected error: client output directory is undefined");