Skip to content

Commit b7436f8

Browse files
authored
Fix @import url() being stripped (#16144)
1 parent 50bafce commit b7436f8

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
- Nothing yet!
10+
### Fixed
11+
12+
- Fix `@import url()` being stripped ([#16144](https://github.com/tailwindlabs/tailwindcss/pull/16144))
1113

1214
## [4.0.2] - 2025-01-31
1315

packages/tailwindcss/src/ast.test.ts

+3
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ it('should not emit empty rules once optimized', () => {
142142
@layer foo, bar, baz;
143143
@custom-media --modern (color), (hover);
144144
@namespace 'http://www.w3.org/1999/xhtml';
145+
@import url('https://fonts.googleapis.com/css2?family=Cedarville+Cursive&display=swap');
145146
`)
146147

147148
expect(toCss(ast)).toMatchInlineSnapshot(`
@@ -174,6 +175,7 @@ it('should not emit empty rules once optimized', () => {
174175
@layer foo, bar, baz;
175176
@custom-media --modern (color), (hover);
176177
@namespace 'http://www.w3.org/1999/xhtml';
178+
@import url('https://fonts.googleapis.com/css2?family=Cedarville+Cursive&display=swap');
177179
"
178180
`)
179181

@@ -182,6 +184,7 @@ it('should not emit empty rules once optimized', () => {
182184
@layer foo, bar, baz;
183185
@custom-media --modern (color), (hover);
184186
@namespace 'http://www.w3.org/1999/xhtml';
187+
@import url('https://fonts.googleapis.com/css2?family=Cedarville+Cursive&display=swap');
185188
"
186189
`)
187190
})

packages/tailwindcss/src/ast.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,8 @@ export function optimizeAst(ast: AstNode[]) {
306306
copy.name === '@layer' ||
307307
copy.name === '@charset' ||
308308
copy.name === '@custom-media' ||
309-
copy.name === '@namespace'
309+
copy.name === '@namespace' ||
310+
copy.name === '@import'
310311
) {
311312
parent.push(copy)
312313
}

0 commit comments

Comments
 (0)