Allow whitespace around @source inline() arg (#19461)

## 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`.
This commit is contained in:
Justin Wong 2025-12-18 15:51:00 +00:00 committed by GitHub
parent 1fbdd51a8d
commit 7fcdd84e56
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 40 additions and 1 deletions

View File

@ -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

View File

@ -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;
}
"
`)
})
})
})

View File

@ -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 (