Skip to content

Ability to use Sveltekit in a mono-repository context such as with Nx #12499

Description

@kristianmandrup

Describe the problem

In response to #12420 where a feature request is requested to form the basis of resolving this issue

Describe the proposed solution

When using sveltekit in a mono-repository context, the build tends to fail with the following error message:

src/app.html does not exist

The error persists if you change the file location from the svelte config.

This is due to the file resolutions being made from the current directory instead of the project's root directory. While it works totally fine in a standalone project, it can't work in a monorepository context.

The proposed solution is provide an option that specifies the root of the project in the vite adapter and to base the file resolution on the new option if it is provided while keeping the default process.cwd() directory if not provided.

The problem is, when using monorepo tooling such as Nx, Turbo, Lerna, etc, you typically run a command from the root, but then use configuration to specify the cwd overrides.

You can do this via vite.config, but sveltekit plugin does not respect that nor can you currently explicitly pass it as a parameter.

Alternatives considered

vite config contains a root option

https://vitejs.dev/config/shared-options.html

root (Default: process.cwd())
Project root directory (where index.html is located). Can be an absolute path, or a path relative to the current working directory.

From Project Root of Vite docs
Similar to static http servers, Vite has the concept of a "root directory" which your files are served from. You will see it referenced as throughout the rest of the docs.

Supposedly "sveltekit plugin does not respect that" so the better, simpler and less intrusive alternative would be to make svelkit simply respect that.

Importance

i cannot use SvelteKit without it

Additional Information

I build the entire remainder of my app centered around Nx so it would be a major pain to have to create a new monolith project solely for my Sveltekit app. I will further investigate the vite config option.

The following is a repo branch demonstrating the current issue: https://github.com/meeroslav/sveltauri/tree/sveltekit-issue

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