Skip to content

getAssetsDirectory produces backslash paths in wrangler.json on Windows #13185

@shulaoda

Description

@shulaoda

Problem

The assets.directory field in the generated wrangler.json uses OS-native path separators. On Windows, this produces backslash paths like ..\client instead of ../client.

This happens in getAssetsDirectory(), which calls nodePath.relative() without normalizing the result:

function getAssetsDirectory(workerOutputDirectory, resolvedViteConfig) {
  const clientOutputDirectory = resolvedViteConfig.environments.client?.build.outDir;
  return nodePath.relative(
    nodePath.resolve(resolvedViteConfig.root, workerOutputDirectory),
    nodePath.resolve(resolvedViteConfig.root, clientOutputDirectory)
  );
}

path.relative() returns OS-native separators (\ on Windows), but wrangler.json is a platform-agnostic config file and should always use forward slashes.

Expected

{ "assets": { "directory": "../client" } }

Actual (on Windows)

{ "assets": { "directory": "..\\client" } }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions