sveltejs / cli

The Svelte CLI
MIT License
261 stars 11 forks source link

`npx sv create` does not add `prettier-plugin-tailwindcss` to `package.json` and `.prettierrc` #220

Open SymphonySimper opened 1 month ago

SymphonySimper commented 1 month ago

When you create a project with sv with prettier and tailwindcss options selected. It does not seem to add tailwind's prettier plugin. This only gets added if run npx sv add tailwind again after the project creation.

Same thing happens when you create a project with tailwind and without prettier. Now if you add prettier with npx sv add prettier. It does not add tailwind's prettier plugin. You have to again run npx sv add tailwind.

But adding tailwind again results with this app.css

--- a/src/app.css
+++ b/src/app.css
@@ -1,3 +1,6 @@
 @import 'tailwindcss/base';
 @import 'tailwindcss/components';
 @import 'tailwindcss/utilities';
+@import 'tailwindcss/base';
+@import 'tailwindcss/components';
+@import 'tailwindcss/utilities';

git diff of project with create and add

Click me Note: I have removed `package-lock.json` for simplification. ```patch diff --git a/.prettierrc b/.prettierrc index 3f7802c..7ebb855 100644 --- a/.prettierrc +++ b/.prettierrc @@ -3,7 +3,7 @@ "singleQuote": true, "trailingComma": "none", "printWidth": 100, - "plugins": ["prettier-plugin-svelte"], + "plugins": ["prettier-plugin-svelte", "prettier-plugin-tailwindcss"], "overrides": [ { "files": "*.svelte", diff --git a/package.json b/package.json index 47529d0..c408054 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "globals": "^15.0.0", "prettier": "^3.3.2", "prettier-plugin-svelte": "^3.2.6", + "prettier-plugin-tailwindcss": "^0.6.5", "svelte": "^5.0.0", "svelte-check": "^4.0.0", "tailwindcss": "^3.4.9", diff --git a/src/app.css b/src/app.css index a31e444..3e0e682 100644 --- a/src/app.css +++ b/src/app.css @@ -1,3 +1,6 @@ @import 'tailwindcss/base'; @import 'tailwindcss/components'; @import 'tailwindcss/utilities'; +@import 'tailwindcss/base'; +@import 'tailwindcss/components'; +@import 'tailwindcss/utilities'; ```
SymphonySimper commented 1 month ago

This still doesn't seem to work in the case where you create a project with tailwind and later add prettier to it.

manuel3108 commented 1 month ago

@AdrianGonz97 Mhmmm, that totally makes sense. But that would require us adding tailwindcss specific stuff to the prettier add-on. Do we want / need to support this use-case?