-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Improve existing project Tailwind CSS schematic integration #31046
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
clydin
merged 3 commits into
angular:main
from
clydin:ng-schematics/tailwind-existing-styles
Aug 28, 2025
Merged
Improve existing project Tailwind CSS schematic integration #31046
clydin
merged 3 commits into
angular:main
from
clydin:ng-schematics/tailwind-existing-styles
Aug 28, 2025
+172
−46
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@clydin
clydin
added
the
target: major
This PR is targeted for the next major release
label
Aug 26, 2025
@clydin
clydin
force-pushed
the
ng-schematics/tailwind-existing-styles
branch
3 times, most recently
from
August 26, 2025 20:39
21aff83
to
c46e88c
Compare
@clydin
clydin
added
the
action: review
The PR is still awaiting reviews from at least one requested reviewer
label
Aug 26, 2025
...ilwind schematic The tailwind schematic's stylesheet injection logic has been updated to support a wider range of project configurations. Previously, it assumed a `styles.css` file was always present, which could cause issues in projects using CSS preprocessors like Sass/SCSS. This change introduces the following logic: - Detects if a global CSS file already exists to add the Tailwind import. - Creates a new `tailwind.css` file if no global CSS file is found. - Updates the build configuration in `angular.json` to include the new `tailwind.css` file. - Updates the `styles` array in all build configurations (`production`, `development`, etc.) to ensure Tailwind is included in all builds. - Ensures the schematic is idempotent by checking for existing Tailwind imports before adding a new one. These changes make the schematic more robust and provide a better user experience for a wider variety of project setups.
... tailwind schematic The Tailwind schematic now intelligently handles existing PostCSS configurations. Instead of unconditionally creating a new `.postcssrc.json` file, the schematic now searches for `postcss.config.json` or `.postcssrc.json` in both the workspace and project roots. If an existing configuration file is found, it is updated with the required `@tailwindcss/postcss` plugin. A new configuration file is only created if one does not already exist. This prevents conflicts and makes the schematic safer to use in projects that already have a customized PostCSS setup.
The tests for the Tailwind schematic have been refactored to improve readability and reduce boilerplate code. Helper functions (`createTestApp`, `getWorkspace`) have been introduced to handle the repetitive setup of the test application and the parsing of the workspace configuration. The existing tests were updated to use these new helpers, making them more concise and easier to maintain.
@clydin
clydin
force-pushed
the
ng-schematics/tailwind-existing-styles
branch
from
August 27, 2025 12:28
c46e88c
to
3d7e9cb
Compare
alan-agius4
alan-agius4
approved these changes
Aug 28, 2025
@alan-agius4
alan-agius4
added
action: merge
The PR is ready for merge by the caretaker
and removed
action: review
The PR is still awaiting reviews from at least one requested reviewer
labels
Aug 28, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The tailwind schematic's stylesheet injection logic has been updated to support a wider range of project configurations. Previously, it assumed a
styles.css
file was always present, which could cause issues in projects using CSS preprocessors like Sass/SCSS.Instead of unconditionally creating a new
.postcssrc.json
file, the schematic now searches forpostcss.config.json
or.postcssrc.json
in both the workspace and project roots. If an existing configuration file is found, it is updated with the required@tailwindcss/postcss
plugin. A new configuration file is only created if one does not already exist.