Skip to content
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

Update TailwindCSS to v4 and added sample config for TALL Stack compatibility. #167

Merged
merged 4 commits into from
Mar 9, 2025

Conversation

omimouni
Copy link
Contributor

@omimouni omimouni commented Mar 1, 2025

Description:

Laravel 12 ships with TailwindCSS 4 by default, which causes compatibility issues when installing and using the TALL stack. This PR updates the necessary packages and adds a sample TailwindCSS 4 configuration file, ensuring it follows the same approach as the forms and typography plugins.

Copy link
Member

Choose a reason for hiding this comment

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

Can we keep the Tailwind in the app.scss instead? Also maybe lets use this opportunity to rename app.scss to app.css since many important sass features like nesting are supported by PostCSS.

At the same time, rename sass to css

Copy link
Contributor Author

@omimouni omimouni Mar 2, 2025

Choose a reason for hiding this comment

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

Done! I did test the package locally on a fresh build as well it seems to work fine.

@n355
Copy link

n355 commented Mar 2, 2025

As per Tailwind CSS's official documentation, when using Tailwind CSS with PostCSS, only @tailwindcss/postcss and postcss are required.
Autoprefixer is not needed as Tailwind now handles prefixing internally.
It might be a good idea to include the @tailwindcss/nesting package to replace Sass nesting functionality.

@danharrin
Copy link
Member

Sure, but we're using it with Vite @n355, which is the default Laravel project implementation

Nesting is already supported in Tailwind 4 without extra plugins AFAIK

@@ -15,7 +15,9 @@ class TallPreset extends Preset
'resolve-url-loader' => '^3.1',
'sass' => '^1.3',
'sass-loader' => '^8.0',
'tailwindcss' => '^3.4',
'tailwindcss' => '^4.0',
'@tailwindcss/postcss' => '^4.0',
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need this, right?

Comment on lines 16 to 17
'sass' => '^1.3',
'sass-loader' => '^8.0',
Copy link
Member

Choose a reason for hiding this comment

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

And I don't think we need these, can you check the rest of the deps please?

@n355
Copy link

n355 commented Mar 2, 2025

@danharrin I tested a Laravel 12 project with postcss and @tailwindcss/postcss. Tailwind works with Vite without the @tailwindcss/vite plugin, FYI.

Note that Tailwind 4's default nesting doesn't support the & parent reference.

@danharrin
Copy link
Member

Look at the Laravel 12 skeleton, there is no Postcss at all

@n355
Copy link

n355 commented Mar 3, 2025

I am well aware that Laravel 12 comes without a PostCSS config, but since I saw in this PR that you were planning to keep it, I was speaking in context—meaning I uninstalled the default Vite plugin to switch to a PostCSS-only setups.
Hope this clarifies my point.

@danharrin
Copy link
Member

I think we should use this PR to slim down the changes required to use the preset, so that means completely removing PostCSS, sass, etc. It will be clearer to people familiar with Laravel 12. We can drop nesting support out of the box if we don't use it in any of our code either.

…oving @tailwindcss/vite and sass, and set PostCSS as default. Added @tailwindcss/nesting for better nesting support and fixed PostCSS config.
@omimouni
Copy link
Contributor Author

omimouni commented Mar 8, 2025

in the last commit I cleaned up package list by removing @tailwindcss/vite and Sass, and set PostCSS as default. Added @tailwindcss/nesting for better nesting and fixed PostCSS config. I tested it and it works well and blazing fast.

@omimouni
Copy link
Contributor Author

omimouni commented Mar 8, 2025

I think we should use this PR to slim down the changes required to use the preset, so that means completely removing PostCSS, sass, etc. It will be clearer to people familiar with Laravel 12. We can drop nesting support out of the box if we don't use it in any of our code either.

I believe keeping PostCSS and nesting functionality would facilitate an easier migration to the newer version of Laravel and the TALL stack while maintaining backward compatibility. Speaking from experience, I've used this package in most of my Laravel projects, and these features have been quite beneficial.

@danharrin
Copy link
Member

This package is for new projects only and not upgrading existing projects, so please remove PostCSS and nesting to keep the installation minimal @omimouni

@n355
Copy link

n355 commented Mar 8, 2025

@omimouni I just ran into build issues with the @tailwindcss/nesting plugin. Turns out it’s not maintained and doesn’t work properly. I’d recommend sticking to the official method with the Vite plugin instead, as @danharrin suggests.

@omimouni
Copy link
Contributor Author

omimouni commented Mar 8, 2025

@n355 @danharrin I kept only the minimal packages for Tailwind CSS to work and configured Vite to match Laravel 12's default setup. I think this is all set now

Copy link
Member

Choose a reason for hiding this comment

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

Lodash is no longer installed by default so we can remove that
Tailwind and Tailwind Vite don't need to be added since they are already in the skeleton

Copy link
Member

Choose a reason for hiding this comment

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

This file can be removed since its the same as the default vite.config.js in the app

Copy link
Member

@danharrin danharrin left a comment

Choose a reason for hiding this comment

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

The tests are failing because of the outdated CI workflow, can you take a look please?

@omimouni
Copy link
Contributor Author

omimouni commented Mar 9, 2025

The tests are failing because of the outdated CI workflow, can you take a look please?

Yes seems like actions/cache v1 was deprecated, I did change it to version v4!

@danharrin danharrin merged commit be542b4 into laravel-frontend-presets:master Mar 9, 2025
1 check passed
@danharrin
Copy link
Member

Thank you

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.

3 participants