File tree Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' sv ' : patch
3+ ---
4+
5+ fix(prettier): add tailwindcss plugin to prettier config if tailwindcss is installed
Original file line number Diff line number Diff line change @@ -8,6 +8,9 @@ export default defineAddon({
88 homepage : 'https://prettier.io' ,
99 options : { } ,
1010 run : ( { sv, dependencyVersion } ) => {
11+ const tailwindcssInstalled = Boolean ( dependencyVersion ( 'tailwindcss' ) ) ;
12+ if ( tailwindcssInstalled ) sv . devDependency ( 'prettier-plugin-tailwindcss' , '^0.7.1' ) ;
13+
1114 sv . devDependency ( 'prettier' , '^3.6.2' ) ;
1215 sv . devDependency ( 'prettier-plugin-svelte' , '^3.4.0' ) ;
1316
@@ -45,13 +48,18 @@ export default defineAddon({
4548 }
4649
4750 data . plugins ??= [ ] ;
48- data . overrides ??= [ ] ;
49-
5051 const plugins : string [ ] = data . plugins ;
52+ if ( tailwindcssInstalled ) {
53+ if ( ! plugins . includes ( 'prettier-plugin-tailwindcss' ) ) {
54+ data . plugins . unshift ( 'prettier-plugin-tailwindcss' ) ;
55+ }
56+ data . tailwindStylesheet ??= './src/app.css' ;
57+ }
5158 if ( ! plugins . includes ( 'prettier-plugin-svelte' ) ) {
5259 data . plugins . unshift ( 'prettier-plugin-svelte' ) ;
5360 }
5461
62+ data . overrides ??= [ ] ;
5563 const overrides : Array < { files : string | string [ ] ; options ?: { parser ?: string } } > =
5664 data . overrides ;
5765 const override = overrides . find ( ( o ) => o ?. options ?. parser === 'svelte' ) ;
Original file line number Diff line number Diff line change @@ -92,6 +92,7 @@ export default defineAddon({
9292
9393 return code ;
9494 } ) ;
95+
9596 if ( ! kit ) {
9697 sv . file ( 'src/App.svelte' , ( content ) => {
9798 const { script, generateCode } = parseSvelte ( content , { typescript } ) ;
@@ -119,7 +120,7 @@ export default defineAddon({
119120 } ) ;
120121 }
121122
122- if ( dependencyVersion ( 'prettier' ) ) {
123+ if ( prettierInstalled ) {
123124 sv . file ( '.prettierrc' , ( content ) => {
124125 const { data, generateCode } = parseJson ( content ) ;
125126 const PLUGIN_NAME = 'prettier-plugin-tailwindcss' ;
You can’t perform that action at this time.
0 commit comments