Skip to content

Commit bc215c2

Browse files
committed
Refactor
1 parent 42b623a commit bc215c2

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

packages/tailwindcss-language-server/src/css/extract-source-directives.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
import type { Plugin } from 'postcss'
2+
import type { SourcePattern } from '../project-locator'
23

3-
export function extractSourceDirectives(sources: string[]): Plugin {
4+
export function extractSourceDirectives(sources: SourcePattern[]): Plugin {
45
return {
56
postcssPlugin: 'extract-at-rules',
67
AtRule: {
78
source: ({ params }) => {
9+
let negated = false
10+
811
if (params[0] !== '"' && params[0] !== "'") return
9-
sources.push(params.slice(1, -1))
12+
13+
sources.push({
14+
pattern: params.slice(1, -1),
15+
negated,
16+
})
1017
},
1118
},
1219
}

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ async function* contentSelectorsFromCssConfig(
623623
async function* detectContentFiles(
624624
base: string,
625625
inputFile: string,
626-
sources: string[],
626+
sources: SourcePattern[],
627627
resolver: Resolver,
628628
): AsyncIterable<string> {
629629
try {
@@ -636,10 +636,10 @@ async function* detectContentFiles(
636636
oxidePath,
637637
oxideVersion: oxidePackageJson.version,
638638
basePath: base,
639-
sources: sources.map((pattern) => ({
639+
sources: sources.map((source) => ({
640640
base: path.dirname(inputFile),
641-
pattern,
642-
negated: false,
641+
pattern: source.pattern,
642+
negated: source.negated,
643643
})),
644644
})
645645

@@ -673,11 +673,16 @@ type ConfigEntry = {
673673
content: ContentItem[]
674674
}
675675

676+
export interface SourcePattern {
677+
pattern: string
678+
negated: boolean
679+
}
680+
676681
class FileEntry {
677682
content: string | null
678683
deps: FileEntry[] = []
679684
realpath: string | null
680-
sources: string[] = []
685+
sources: SourcePattern[] = []
681686
meta: TailwindStylesheet | null = null
682687

683688
constructor(

0 commit comments

Comments
 (0)