Skip to content

Commit 05a0342

Browse files
committed
Ignore @tailwind utilities inside @reference
It’s triggering content scans and it doesn’t need to as no utilities in here will be printed anyway
1 parent 490767b commit 05a0342

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

packages/tailwindcss/src/index.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5478,7 +5478,7 @@ describe('feature detection', () => {
54785478
expect(compiler.features & Features.Variants).toBeFalsy()
54795479
})
54805480

5481-
test('`@tailwind utilities` is discovered inside `@reference`', async () => {
5481+
test('`@tailwind utilities` is ignored inside `@reference`', async () => {
54825482
let compiler = await compile(
54835483
css`
54845484
@reference "tailwindcss/utilities";
@@ -5497,6 +5497,6 @@ describe('feature detection', () => {
54975497

54985498
// We see @tailwind utilities but because of @reference it is ignored
54995499
expect(compiler.features & Features.AtImport).toBeTruthy()
5500-
expect(compiler.features & Features.Utilities).toBeTruthy()
5500+
expect(compiler.features & Features.Utilities).toBeFalsy()
55015501
})
55025502
})

packages/tailwindcss/src/index.ts

+8
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,14 @@ async function parseCss(
162162
return
163163
}
164164

165+
// When inside `@reference` we should treat `@tailwind utilities` as if
166+
// it wasn't there in the first place. This should also let `build()`
167+
// return the cached static AST.
168+
if (context.reference) {
169+
replaceWith([])
170+
return
171+
}
172+
165173
let params = segment(node.params, ' ')
166174
for (let param of params) {
167175
if (param.startsWith('source(')) {

0 commit comments

Comments
 (0)