svelte-add icon indicating copy to clipboard operation
svelte-add copied to clipboard

fix: install the correct `+layout.svelte` file for Tailwind adder

Open AdrianGonz97 opened this issue 9 months ago • 2 comments

For the tailwind adder, +layout.js was being installed instead of the needed +layout.svelte file.

AdrianGonz97 avatar May 06 '24 23:05 AdrianGonz97

Thanks for your contribution!

Could you enlighten me under which circumstances this was not working properly? Because I'm pretty sure this was working this weekend and the last pipeline runs also seem successful.

manuel3108 avatar May 07 '24 04:05 manuel3108

Sure, here's a base repro as a starting point (just a basic create-svelte template): https://github.com/AdrianGonz97/svelte-add-tailwind-layout-repro

  1. git clone https://github.com/AdrianGonz97/svelte-add-tailwind-layout-repro
  2. pnpm install
  3. pnpm dlx @svelte-add/tailwindcss@latest --typography false
  4. Select pnpm for the dependency install option

Notice how it will import the stylesheet in src/routes/+layout.js instead of a layout component file.

Edit:

Could you enlighten me under which circumstances this was not working properly?

Reading this again, are you asking why we should move the stylesheet import back into a svelte component if it's already working in a loader? In that case, sure, it technically works, but it's a bit weird importing a stylesheet into a file that's meant for isomorphic loaders. Given that stylesheets directly affect the UI, and Svelte components are designed for building UIs, I think it'd make the most sense to keep the import in a svelte file.

AdrianGonz97 avatar May 07 '24 04:05 AdrianGonz97

Thanks for your input!

I'm honestly not sure what is the correct way to implement this. I tried searching for best practices inside the docs, but I was unable to do find anything. Based on that I have create an issue in the official kit repo in the hope of getting some good answers there: https://github.com/sveltejs/kit/issues/12202

manuel3108 avatar May 09 '24 08:05 manuel3108

Based on the feedback we got, it looks like you made the right call!

I have adapted the other adders as well, and I'm going to merge once the tests pass!

manuel3108 avatar May 10 '24 16:05 manuel3108