Skip to content

Commit 9855d12

Browse files
committed
ignore all errors
If any of the errors occur, we can bail and keep the `@import` in the final CSS. If something went wrong, the browser will let you know that something is missing.
1 parent 672f7cb commit 9855d12

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

packages/tailwindcss/src/at-import.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ export function parseImportParams(params: ValueParser.ValueAstNode[]) {
7777
if (node.kind === 'separator') continue
7878

7979
if (node.kind === 'word' && !uri) {
80-
if (!node.value) throw new Error(`Unable to find uri`)
81-
if (node.value[0] !== '"' && node.value[0] !== "'") throw new Error('Unable to find uri')
80+
if (!node.value) return null
81+
if (node.value[0] !== '"' && node.value[0] !== "'") return null
8282

8383
uri = node.value.slice(1, -1)
8484
continue
@@ -91,17 +91,18 @@ export function parseImportParams(params: ValueParser.ValueAstNode[]) {
9191
return null
9292
}
9393

94-
if (!uri) throw new Error('Unable to find uri')
94+
if (!uri) return null
9595

9696
if (
9797
(node.kind === 'word' || node.kind === 'function') &&
9898
node.value.toLowerCase() === 'layer'
9999
) {
100-
if (layer) throw new Error('Multiple layers')
101-
if (supports)
100+
if (layer) return null
101+
if (supports) {
102102
throw new Error(
103103
'`layer(…)` in an `@import` should come before any other functions or conditions',
104104
)
105+
}
105106

106107
if ('nodes' in node) {
107108
layer = ValueParser.toCss(node.nodes)
@@ -113,7 +114,7 @@ export function parseImportParams(params: ValueParser.ValueAstNode[]) {
113114
}
114115

115116
if (node.kind === 'function' && node.value.toLowerCase() === 'supports') {
116-
if (supports) throw new Error('Multiple support conditions')
117+
if (supports) return null
117118
supports = ValueParser.toCss(node.nodes)
118119
continue
119120
}
@@ -122,7 +123,7 @@ export function parseImportParams(params: ValueParser.ValueAstNode[]) {
122123
break
123124
}
124125

125-
if (!uri) throw new Error('Unable to find uri')
126+
if (!uri) return null
126127

127128
return { uri, layer, media, supports }
128129
}

0 commit comments

Comments
 (0)