-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor * Support customizing directory of an opened completion document * Add notes * Resolve `style` exports field in postcss import * Update changelog * Add test * Refactor * Make sure the main `style` field is still supported
- Loading branch information
1 parent
37c4b96
commit cf97d7a
Showing
17 changed files
with
134 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
packages/tailwindcss-language-server/src/resolve-css-imports.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import postcss from 'postcss' | ||
import postcssImport from 'postcss-import' | ||
import { createResolver } from './util/resolve' | ||
|
||
const resolver = createResolver({ | ||
extensions: ['.css'], | ||
mainFields: ['style'], | ||
conditionNames: ['style'], | ||
}) | ||
|
||
const resolveImports = postcss([ | ||
postcssImport({ | ||
resolve(id, basedir) { | ||
let paths = resolver.resolveSync({}, basedir, id) | ||
return paths | ||
? paths | ||
: id | ||
}, | ||
}), | ||
]) | ||
|
||
export function resolveCssImports() { | ||
return resolveImports | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import * as fs from 'fs' | ||
import { | ||
CachedInputFileSystem, | ||
ResolverFactory, | ||
Resolver, | ||
ResolveOptions, | ||
} from 'enhanced-resolve-301' | ||
|
||
export function createResolver(options: Partial<ResolveOptions> = {}): Resolver { | ||
return ResolverFactory.createResolver({ | ||
fileSystem: new CachedInputFileSystem(fs, 4000), | ||
useSyncFileSystemCalls: true, | ||
conditionNames: ['node', 'require'], | ||
...options, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
packages/tailwindcss-language-server/tests/fixtures/v4/workspaces/package-lock.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
...es/tailwindcss-language-server/tests/fixtures/v4/workspaces/packages/style-export/lib.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@theme { | ||
--color-beet: #8e3b46; | ||
} |
9 changes: 9 additions & 0 deletions
9
...ilwindcss-language-server/tests/fixtures/v4/workspaces/packages/style-export/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "@private/style-export", | ||
"exports": { | ||
".": { | ||
"style": "./lib.css" | ||
}, | ||
"./theme": "./theme.css" | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
.../tailwindcss-language-server/tests/fixtures/v4/workspaces/packages/style-export/theme.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@theme { | ||
--color-orangepeel: #ff9f00; | ||
} |
3 changes: 3 additions & 0 deletions
3
...ailwindcss-language-server/tests/fixtures/v4/workspaces/packages/style-main-field/lib.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@theme { | ||
--color-style-main: #8e3b46; | ||
} |
4 changes: 4 additions & 0 deletions
4
...ndcss-language-server/tests/fixtures/v4/workspaces/packages/style-main-field/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "@private/style-main-field", | ||
"style": "./lib.css" | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/tailwindcss-language-server/tests/fixtures/v4/workspaces/packages/web/app.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
@import 'tailwindcss'; | ||
@import '@private/shared/ui.css'; | ||
@import '@private/style-export'; | ||
@import '@private/style-export/theme'; | ||
@import '@private/style-main-field'; | ||
|
||
@theme { | ||
--color-potato: #907a70; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters