Skip to content

[12.x] Remove not necessary tailwindcss source declarations #6588

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

Closed
wants to merge 1 commit into from

Conversation

rozsazoltan
Copy link

In PR #6523, the settings ensuring TailwindCSS v4 compatibility were added to version 12.x. However, three of the declared sources are unnecessary and only increase the codebase size.

TailwindCSS v4 automatically detects all sources that are not in .gitignore and are not special files. See more details here:

Resources

As a result, there is no need to declare resources/**/*.blade.php and resources/**/*.js as sources.

Storage Views

Additionally, scanning cached files in storage/framework/views/*.php is unnecessary, as TailwindCSS can discover the required classes by mapping the original source files.

Mapping cached files can lead to incorrect results if the developer dynamically constructs class names, e.g., bg-red-$custom, where $custom might default to 500. In this case, due to the storage source, bg-red-500 will be added to the prod, but the other classes won't, and the developer won't understand the explanation.

To avoid this, the TailwindCSS v4 documentation specifically advises developers to avoid such dynamic declarations.

So, if the classes are properly declared in the source (whether in app, resources, or elsewhere), they will be correctly included in the compiled CSS without the need to consider the storage folder.

@rozsazoltan
Copy link
Author

To be honest, I would also remove the source pointing to pagination; it's understandably included since .gitignore excludes the contents of the vendor folder, and thus TailwindCSS does not automatically map it.

The missing of the source in this case creates an extra issue for developers using pagination when adding it.

Having the source included, on the other hand, adds a few classes that developers who never use pagination might never utilize.

By the way, the pagination documentation covers the correct implementation, so it might even make sense to remove it by default:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants