From b7436f8b5942d9e64765eb5fced0eabd46ca717b Mon Sep 17 00:00:00 2001 From: Justin Wong <11310624+wongjn@users.noreply.github.com> Date: Sat, 1 Feb 2025 11:16:16 +0000 Subject: [PATCH] Fix `@import url()` being stripped (#16144) --- CHANGELOG.md | 4 +++- packages/tailwindcss/src/ast.test.ts | 3 +++ packages/tailwindcss/src/ast.ts | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d61bfc1eec4b..74ea882ff2b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/packages/tailwindcss/src/ast.test.ts b/packages/tailwindcss/src/ast.test.ts index 174971ea541d..142fd6312ccf 100644 --- a/packages/tailwindcss/src/ast.test.ts +++ b/packages/tailwindcss/src/ast.test.ts @@ -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'); " `) }) diff --git a/packages/tailwindcss/src/ast.ts b/packages/tailwindcss/src/ast.ts index 7f67fdda5f57..ac4529e87000 100644 --- a/packages/tailwindcss/src/ast.ts +++ b/packages/tailwindcss/src/ast.ts @@ -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) }