Skip to content

Build fails with adapter-cloudflare when config.kit.paths.base is used #13769

@adriansaelen

Description

@adriansaelen

Describe the bug

I have a few projects that make use of the config.kit.paths.base setting, and after updating adapter-cloudflare to v7.0.2, our build breaks/fails on the sites that use that setting.

Error message:

✓ built in 958ms

Run npm run preview to preview your production build locally.

> Using @sveltejs/adapter-cloudflare
error during build:
Error: ENOENT: no such file or directory, open '---/.svelte-kit/cloudflare/base/404.html

Reproduction

https://github.com/adriansaelen/sveltekit-base-adapter-cloudflare-bug

Logs

System Info

System:
    OS: macOS 15.4.1
    CPU: (10) arm64 Apple M2 Pro
    Memory: 113.58 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.15.1 - ~/.nvm/versions/node/v20.15.1/bin/node
    npm: 10.9.0 - ~/.nvm/versions/node/v20.15.1/bin/npm
    pnpm: 10.9.0 - ~/.nvm/versions/node/v20.15.1/bin/pnpm
  Browsers:
    Chrome: 135.0.7049.116
    Safari: 18.4
  npmPackages:
    @sveltejs/adapter-auto: ^6.0.0 => 6.0.0 
    @sveltejs/adapter-cloudflare: ^7.0.2 => 7.0.2 
    @sveltejs/kit: ^2.16.0 => 2.20.8 
    @sveltejs/vite-plugin-svelte: ^5.0.0 => 5.0.3 
    svelte: ^5.0.0 => 5.28.2 
    vite: ^6.2.6 => 6.3.5

Severity

serious, but I can work around it

Additional Information

I believe the issue is that the "base" folder isn't available when it's trying to write the 404.html file:

writeFileSync(fallback, 'Not Found');

Below the following:

const assets_dest = `${dest}${builder.config.kit.paths.base}`;

I added this code:

if (!existsSync(assets_dest)) {
  builder.mkdirp(assets_dest);
}

and that did the trick for me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions