Skip to content

Commit cb09921

Browse files
Handle postcss throwing when parsing more complex files (#1043)
Fixes: #1033 Fixes: #1034 Fixes: #1035 Fixes: #1036 Fixes: #1037 Fixes: #1038 Fixes: #1039 Fixes: #1040 Fixes: #1041 Fixes: #1042 Fixes: tailwindlabs/tailwindcss#14274 When we worked on #1030, we added a new `postcss` run inside the project locator. Unfortunately this can crash (e.g. when non standard CSS features are discovered like those in a `.sass` or `.scss` file) which currently breaks the whole project locator step, making the extension not work anymore as soon as such a file is detected. The short term fix here is to handle this error. In the very future we have to replace this postcss step anyways because now that Tailwind v4 supports plugins and JS config files, we need to be able to execute the config to get the proper sources. ## Before <img width="659" alt="before" src="https://github.com/user-attachments/assets/8f86e70d-66c2-40a1-ba97-9f4b9b018c94"> ## After <img width="656" alt="after" src="https://github.com/user-attachments/assets/bfd17b72-c748-4ea9-b73d-86c444cda16a">
1 parent 5e308e8 commit cb09921

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

packages/tailwindcss-language-server/src/project-locator.ts

+14-10
Original file line numberDiff line numberDiff line change
@@ -615,17 +615,21 @@ class FileEntry {
615615
}
616616

617617
async resolveSourceDirectives() {
618-
if (this.sources.length > 0) {
619-
return
620-
}
618+
try {
619+
if (this.sources.length > 0) {
620+
return
621+
}
621622

622-
// Note: This should eventually use the DesignSystem to extract the same
623-
// sources also discovered by tailwind. Since we don't have everything yet
624-
// to initialize the design system though, we set up a simple postcss at
625-
// rule exporter instead for now.
626-
await postcss([extractSourceDirectives(this.sources)]).process(this.content, {
627-
from: this.realpath,
628-
})
623+
// Note: This should eventually use the DesignSystem to extract the same
624+
// sources also discovered by tailwind. Since we don't have everything yet
625+
// to initialize the design system though, we set up a simple postcss at
626+
// rule exporter instead for now.
627+
await postcss([extractSourceDirectives(this.sources)]).process(this.content, {
628+
from: this.realpath,
629+
})
630+
} catch (err) {
631+
//
632+
}
629633
}
630634

631635
/**

packages/vscode-tailwindcss/CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Prerelease
44

5-
- Nothing yet!
5+
- Fix an issue that caused the language server for any project with a non-standard CSS file to crash ([#1030](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1030))
66

77
## 0.12.7
88

0 commit comments

Comments
 (0)