Fix @import url() being stripped (#16144)

This commit is contained in:
Justin Wong 2025-02-01 11:16:16 +00:00 committed by GitHub
parent 50bafce756
commit b7436f8b59
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 2 deletions

View File

@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
- Nothing yet!
### Fixed
- Fix `@import url()` being stripped ([#16144](https://github.com/tailwindlabs/tailwindcss/pull/16144))
## [4.0.2] - 2025-01-31

View File

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

View File

@ -306,7 +306,8 @@ export function optimizeAst(ast: AstNode[]) {
copy.name === '@layer' ||
copy.name === '@charset' ||
copy.name === '@custom-media' ||
copy.name === '@namespace'
copy.name === '@namespace' ||
copy.name === '@import'
) {
parent.push(copy)
}