From 7fcdd84e568380464fbf0086fb64c8a2c146ca2b Mon Sep 17 00:00:00 2001 From: Justin Wong <11310624+wongjn@users.noreply.github.com> Date: Thu, 18 Dec 2025 15:51:00 +0000 Subject: [PATCH] Allow whitespace around `@source inline()` arg (#19461) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Inspired by #19460, relaxes whitespace syntax around `@source inline(…):` ### Before ```css /* ❌ Error: `@source` paths must be quoted. */ @source inline( "underline" ); @source inline( "underline" ); ``` ### After ```css /* ✅ Generates the class names as normal. */ @source inline( "underline" ); @source inline( "underline" ); ``` ## Test plan Added tests to `packages/tailwindcss/src/index.test.ts`. --- CHANGELOG.md | 1 + packages/tailwindcss/src/index.test.ts | 38 ++++++++++++++++++++++++++ packages/tailwindcss/src/index.ts | 2 +- 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7829df19c..be8ec9aef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Do not wrap `color-mix` in a `@supports` rule if one already exists ([#19450](https://github.com/tailwindlabs/tailwindcss/pull/19450)) +- Allow whitespace around `@source inline()` argument ([#19461](https://github.com/tailwindlabs/tailwindcss/pull/19461)) ### Added diff --git a/packages/tailwindcss/src/index.test.ts b/packages/tailwindcss/src/index.test.ts index 595950464..2d6ab8daf 100644 --- a/packages/tailwindcss/src/index.test.ts +++ b/packages/tailwindcss/src/index.test.ts @@ -3802,6 +3802,44 @@ describe('@source', () => { expect(build(['bg-red-500', 'bg-red-700'])).toMatchInlineSnapshot(`""`) }) + + test('works with whitespace around the argument', async () => { + let { build } = await compile( + css` + /* prettier-ignore */ + @source inline( "underline" ); + @tailwind utilities; + `, + { base: '/root' }, + ) + + expect(build([])).toMatchInlineSnapshot(` + ".underline { + text-decoration-line: underline; + } + " + `) + }) + + test('works with newlines around the argument', async () => { + let { build } = await compile( + css` + /* prettier-ignore */ + @source inline( + "underline" + ); + @tailwind utilities; + `, + { base: '/root' }, + ) + + expect(build([])).toMatchInlineSnapshot(` + ".underline { + text-decoration-line: underline; + } + " + `) + }) }) }) diff --git a/packages/tailwindcss/src/index.ts b/packages/tailwindcss/src/index.ts index 512c2f831..a511b0838 100644 --- a/packages/tailwindcss/src/index.ts +++ b/packages/tailwindcss/src/index.ts @@ -274,7 +274,7 @@ async function parseCss( if (path[0] === 'i' && path.startsWith('inline(')) { inline = true - path = path.slice(7, -1) + path = path.slice(7, -1).trim() } if (