Skip to content

Commit ab582dc

Browse files
committed
only error on imports with theme(reference)
1 parent 132071d commit ab582dc

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

packages/tailwindcss/src/index.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,18 +380,24 @@ async function parseCss(
380380

381381
// Handle `@media theme(…)`
382382
//
383-
// We support `@import "tailwindcss/theme" theme(reference)` as a way to
383+
// We support `@import "tailwindcss" theme(reference)` as a way to
384384
// import an external theme file as a reference, which becomes `@media
385385
// theme(reference) { … }` when the `@import` is processed.
386386
else if (param.startsWith('theme(')) {
387387
let themeParams = param.slice(6, -1)
388+
let hasReference = themeParams.includes('reference')
388389

389390
walk(node.nodes, (child) => {
390391
if (child.kind !== 'at-rule') {
391-
throw new Error(
392-
'Files imported with `@import "…" theme(…)` must only contain `@theme` blocks.',
393-
)
392+
if (hasReference) {
393+
throw new Error(
394+
`Files imported with \`@import "…" theme(reference)\` must only contain \`@theme\` blocks.\nUse \`@reference "…";\` instead.`,
395+
)
396+
}
397+
398+
return WalkAction.Continue
394399
}
400+
395401
if (child.name === '@theme') {
396402
child.params += ' ' + themeParams
397403
return WalkAction.Skip

0 commit comments

Comments
 (0)