Skip to content

Commit 5c5ac03

Browse files
committed
wip
1 parent 7821a89 commit 5c5ac03

File tree

2 files changed

+65
-3
lines changed

2 files changed

+65
-3
lines changed

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

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { expect, test } from 'vitest'
1+
import { expect, test, TestOptions } from 'vitest'
22
import * as path from 'node:path'
33
import { ProjectLocator } from './project-locator'
44
import { URL, fileURLToPath } from 'url'
55
import { Settings } from '@tailwindcss/language-service/src/util/state'
66
import { createResolver } from './resolver'
7-
import { css, defineTest, js, json, scss, Storage, TestUtils } from './testing'
7+
import { css, defineTest, html, js, json, scss, Storage, TestUtils } from './testing'
88

99
let settings: Settings = {
1010
tailwindCSS: {
@@ -279,23 +279,78 @@ testLocator({
279279
],
280280
})
281281

282+
testLocator({
283+
options: { only: true },
284+
285+
// Don't exclude any files when searching
286+
settings: {
287+
tailwindCSS: { files: { exclude: [] } } as any,
288+
},
289+
290+
name: 'wip',
291+
fs: {
292+
'packages/a/package.json': json`
293+
{
294+
"dependencies": {
295+
"tailwindcss": "4.0.0"
296+
}
297+
}
298+
`,
299+
'packages/a/styles.css': css`
300+
@import 'tailwindcss';
301+
@theme {
302+
--color-primary: #c0ffee;
303+
}
304+
`,
305+
'packages/a/index.html': html` <div class="underline"></div> `,
306+
'packages/b/package.json': json`
307+
{
308+
"dependencies": {
309+
"tailwindcss": "3.4.17"
310+
}
311+
}
312+
`,
313+
'packages/b/styles.css': css`
314+
@tailwind base;
315+
@tailwind utilities;
316+
@tailwind components;
317+
`,
318+
'packages/b/index.html': html` <div class="underline"></div> `,
319+
},
320+
expected: [
321+
{
322+
version: '4.0.0',
323+
config: '/packages/a/node_modules/tailwindcss/utilities.css',
324+
content: [],
325+
},
326+
{
327+
version: '4.0.0',
328+
config: '/packages/a/styles.css',
329+
content: [],
330+
},
331+
],
332+
})
333+
282334
// ---
283335

284336
function testLocator({
285337
name,
286338
fs,
287339
expected,
288340
settings,
341+
options,
289342
}: {
290343
name: string
291344
fs: Storage
292345
settings?: Partial<Settings>
346+
options?: TestOptions
293347
expected: any[]
294348
}) {
295349
defineTest({
296350
name,
297351
fs,
298352
prepare,
353+
options,
299354
async handle({ search }) {
300355
let projects = await search(settings)
301356

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,14 @@ export class ProjectLocator {
257257
// Look for config files and CSS files
258258
let files = await glob([`**/${CONFIG_GLOB}`, `**/${CSS_GLOB}`], {
259259
cwd: this.base,
260-
ignore: this.settings.tailwindCSS.files.exclude,
260+
ignore: [
261+
...this.settings.tailwindCSS.files.exclude,
262+
263+
// If we're looking at a tailwind.config.js (or similar file) that's inside
264+
// a node_modules/tailwindcss directory, we should ignore it because those
265+
// files are "stubs" and not meant to be used as a project config
266+
`**/node_modules/tailwindcss/**/${CONFIG_GLOB}`,
267+
],
261268
onlyFiles: true,
262269
absolute: true,
263270
suppressErrors: true,

0 commit comments

Comments
 (0)