You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using Nx it is currently not possible to run sveltekit with the normal build commands. We have a workaround for this by adding the following configuration to our application:
However, this setup breaks several things like the nx dependency tree.
Expected Behavior
I would like to be able to run the nx commands when using sveltekit.
This problem is also already described a topic within the sveltekit repository, but as you can see. Sveltekit redirects the questions for this support to the monorepo tooling.
I investigated this issue a while ago and can provide some insights. As you pointed out, Nx and SvelteKit both assume they will be executed from the root of the repository, which creates a conflict. Nx, as a monorepo management tool, appropriately requires execution from the root since it coordinates projects across the entire workspace. SvelteKit, however, operates as a single-project framework and should ideally support being run from any directory, but currently, it enforces being run from the root as well.
With this understanding, I reverse-engineered SvelteKit's behavior and developed a simple workaround that maintains Nx's full functionality while allowing SvelteKit to operate. However, this solution is a hack and depends on the current implementations of Nx and SvelteKit. Future changes in either tool could render it ineffective, which is why I ultimately decided to avoid using SvelteKit in my project.
If you'd like to try the workaround, the implementation is as follows:
import{defineConfig}from'vite';importsveltekitfrom'@sveltejs/kit/vite';constsveltekitFix=async()=>{constcwd=process.cwd();process.chdir(__dirname);// Temporarily change the working directoryconstplugin=awaitsveltekit();// Load the SvelteKit pluginprocess.chdir(cwd);// Restore the original working directoryreturnplugin;};exportdefaultdefineConfig({
...
plugins: [svelteKitPlugin(),// Include the SvelteKit plugin with the workaround
...
],
...
});
I hope this solution proves helpful for your setup. Best of luck with your project!
Current Behavior
When using Nx it is currently not possible to run sveltekit with the normal build commands. We have a workaround for this by adding the following configuration to our application:
However, this setup breaks several things like the nx dependency tree.
Expected Behavior
I would like to be able to run the nx commands when using sveltekit.
This problem is also already described a topic within the sveltekit repository, but as you can see. Sveltekit redirects the questions for this support to the monorepo tooling.
sveltejs/kit#12499
GitHub Repo
No response
Steps to Reproduce
See: sveltejs/kit#12499
Nx Report
Failure Logs
Package Manager Version
No response
Operating System
Additional Information
See: sveltejs/kit#12499
The text was updated successfully, but these errors were encountered: