Skip to content

Sveltekit: svelte-add is not working #441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
scorsi opened this issue Jan 26, 2022 · 6 comments
Open

Sveltekit: svelte-add is not working #441

scorsi opened this issue Jan 26, 2022 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@scorsi
Copy link

scorsi commented Jan 26, 2022

Describe the bug
When running nx add {sveltekit-app} --package {package} it fails with error.

To Reproduce
Steps to reproduce the behavior:
I simply create a new project with sveltekit plugin:

nx g @nxext/sveltekit:app frontend
nx add frontend --package tailwindcss

Expected behavior
Should work :)

Additional context

❯ nx add frontend --package tailwindcss
➕ Svelte Add (Version 2022.01.19.00)
There is no valid Svelte project in this directory because there doesn't seem to be a bundler installed (Vite, Rollup, Snowpack, or webpack).
Create or find an existing issue at https://github.com/svelte-add/svelte-add/issues if this is wrong.
ERROR: Something went wrong in @nrwl/run-commands - Command failed: npx svelte-add tailwindcss
@scorsi scorsi added the bug Something isn't working label Jan 26, 2022
@DominikPieper DominikPieper self-assigned this Feb 9, 2022
@DominikPieper
Copy link
Member

Hey, sorry for the delay. I'll try to fix it soon. Unfortunately, Sveeltekit didn't get much love for some time. Now where it's nearer to the 1.0 I hope the API stays more stable. Unfortunately, the Sveltekit CLI doesn't give a lot of possibilities to manipulate e.g. the output folder to match the Nx folder scheme and that makes the integration at all really hard

@scorsi
Copy link
Author

scorsi commented Feb 10, 2022

I understand ! To be honest I left NX to have a old styled monorepo.
I run into too much issues with SvelteKit and Firebase inside NX... I keep an eye at your extensions ;)

@ecstrema
Copy link
Contributor

ecstrema commented Feb 22, 2022

Hey, sorry for the delay. I'll try to fix it soon. Unfortunately, Sveeltekit didn't get much love for some time. Now where it's nearer to the 1.0 I hope the API stays more stable. Unfortunately, the Sveltekit CLI doesn't give a lot of possibilities to manipulate e.g. the output folder to match the Nx folder scheme and that makes the integration at all really hard

The default output folder can be set with kit.vite.build.outputDir (or something alike).

The output folder for packaging can be set with kit.package.dir option.

That's not the cli, but it still provides the necessary options.

I'm currently using the sveltekit plugin, and it works perfectly. I simply had to change svelte.config.js to:

import preprocess from 'svelte-preprocess';

/** @type {import('@sveltejs/kit').Config} */
const config = {
    // Consult https://github.com/sveltejs/svelte-preprocess
    // for more information about preprocessors
    preprocess: preprocess(),

    kit: {
        package: {
            dir: "../../dist/packages/svelte/package"
        },
        vite: {
            build: {
                outDir: "../../dist/packages/svelte/build"
            }
        }
    },
};

export default config;

Btw, that last fix removing target="#svelte" is great. Could it be published on npm?

@DominikPieper
Copy link
Member

@Marr11317 oh great thank you. Seems I have to take a look at it again. I’ll release a new version soon and add your suggestion as well.

@ecstrema
Copy link
Contributor

Apparently, the value for kit.vite.build.outDir is controlled by svelte and cannot be customised. I'll open an issue.

@ecstrema
Copy link
Contributor

see sveltejs/kit#4052

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants