Skip to content

fix(@schematics/angular): ignore non-workspace stylesheet entries when adding Tailwind - #34507

Merged
alan-agius4 merged 1 commit into
angular:mainfrom
MeAkib:fix/tailwind-vendor-stylesheets
Oct 27, 2026
Merged

alan-agius4 merged 1 commit into
angular:mainfrom
MeAkib:fix/tailwind-vendor-stylesheets

Conversation

@MeAkib

@MeAkib MeAkib commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

The tailwind schematic selects the first styles entry ending in .css and appends the Tailwind import to it without checking that the entry is a file in the workspace. When the first .css entry is a package specifier such as @angular/material/prebuilt-themes/azure-blue.css, ng add tailwindcss fails with a file-does-not-exist exception, and when it is a path within node_modules, the vendor stylesheet is modified instead of a project file. Only consider entries that exist in the workspace and are not within node_modules, falling back to creating a dedicated tailwind.css otherwise. New specs reproduce both failures without this change.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the Tailwind schematic to only modify workspace source files, ensuring that external package specifiers and files within node_modules are not modified. It also adds unit tests to cover these scenarios. A review comment suggests enhancing the node_modules path check to also exclude paths starting with ./node_modules/ for robustness.

Comment thread packages/schematics/angular/tailwind/index.ts Outdated
Comment thread packages/schematics/angular/tailwind/index.ts Outdated
Comment thread packages/schematics/angular/tailwind/index_spec.ts
@MeAkib
MeAkib force-pushed the fix/tailwind-vendor-stylesheets branch from b2eca96 to 9b9cda4 Compare October 23, 2026 17:23
@alan-agius4 alan-agius4 added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Oct 27, 2026
…n adding Tailwind

The tailwind schematic selects the first `styles` entry ending in `.css` and
appends the Tailwind import to it without checking that the entry is a file in
the workspace. When the first `.css` entry is a package specifier such as
`@angular/material/prebuilt-themes/azure-blue.css`, `ng add tailwindcss` fails
with a file-does-not-exist exception, and when it is a path within
`node_modules`, the vendor stylesheet is modified instead of a project file.
Only consider entries that exist in the workspace and are not within
`node_modules`, falling back to creating a dedicated `tailwind.css` otherwise.
New specs reproduce both failures without this change.
@alan-agius4
alan-agius4 force-pushed the fix/tailwind-vendor-stylesheets branch from 9b9cda4 to 01c9fbf Compare October 27, 2026 14:27
@alan-agius4 alan-agius4 added target: patch This PR is targeted for the next patch release and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Oct 27, 2026

@alan-agius4 alan-agius4 left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@alan-agius4 alan-agius4 added the action: merge The PR is ready for merge by the caretaker label Oct 27, 2026
@alan-agius4
alan-agius4 merged commit a68d0df into angular:main Oct 27, 2026
40 of 41 checks passed
@alan-agius4

Copy link
Copy Markdown
Collaborator

This PR was merged into the repository. The changes were merged into the following branches:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @schematics/angular target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants