Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Jan 30, 2025
1 parent c9c69ee commit 8cb65d7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/presets/cloudflare/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ export interface CloudflareOptions {
wrangler?: WranglerConfig;

/**
* Disable the automatic generation of the Wrangler configuration file.
* Disable the automatic generation of .wrangler/deploy/config.json
*/
noWranglerConfig?: boolean;
noWranglerDeployConfig?: boolean;

pages: {
/**
Expand Down
29 changes: 13 additions & 16 deletions src/presets/cloudflare/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,6 @@ export async function writeCFPagesRedirects(nitro: Nitro) {

// https://developers.cloudflare.com/workers/wrangler/configuration/#generated-wrangler-configuration
export async function writeWranglerConfig(nitro: Nitro, isPages: boolean) {
// Allow skipping generated wrangler.json
if (nitro.options.cloudflare?.noWranglerConfig) {
return;
}

// Compute path to generated wrangler.json
const wranglerConfigDir = nitro.options.output.serverDir;
const wranglerConfigPath = join(wranglerConfigDir, "wrangler.json");
Expand Down Expand Up @@ -239,17 +234,19 @@ export async function writeWranglerConfig(nitro: Nitro, isPages: boolean) {
);

// Write .wrangler/deploy/config.json (redirect file)
const configPath = join(
nitro.options.rootDir,
".wrangler/deploy/config.json"
);
await writeFile(
configPath,
JSON.stringify({
configPath: relative(dirname(configPath), wranglerConfigPath),
}),
true
);
if (!nitro.options.cloudflare?.noWranglerDeployConfig) {
const configPath = join(
nitro.options.rootDir,
".wrangler/deploy/config.json"
);
await writeFile(
configPath,
JSON.stringify({
configPath: relative(dirname(configPath), wranglerConfigPath),
}),
true
);
}
}

async function resolveWranglerConfig(dir: string): Promise<WranglerConfig> {
Expand Down

0 comments on commit 8cb65d7

Please sign in to comment.