-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Refactor tailwind integration setup #5717
Conversation
🦋 Changeset detectedLatest commit: 13387d4 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Marking as draft. This depends on #5685 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! I fear a little bit that some users will get confused by autoprefixer not being on in dev, but if we communicate it enough it'll be fine, I think
Good point. I've updated the tailwind readme to reflect that. It also doesn't look like we mention autoprefixer anywhere before, so this seems like a good time to bring up. cc @withastro/maintainers-docs for review! |
Co-authored-by: Sarah Rainsberger <[email protected]>
return { | ||
css: { | ||
postcss: { | ||
plugins: postcssPlugins, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bluwy Setting an inline PostCSS config in Vite, has the effect that Vite no longer looks for postcss.config.cjs
.
See:
Note if an inline config is provided, Vite will not search for other PostCSS config sources.
https://vitejs.dev/config/shared-options.html#css-postcss
That results in by adding the Tailwind Integration 3.0.0-beta.x, postcss.config.cjs
no longer work as described in the Astro Docs.
https://docs.astro.build/en/guides/styling/#postcss
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm that's true, but I think that happens before this PR too as Astro was assigning to the property internally:
I guess for the tailwind integration we need to read postcss.config.js
too to resolve this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirming, trying latest @beta
packages makes Tailwind to ignore postcss.config.js
(f.e. to enable nesting)
Seem to be addressed in: #5908
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seem to be addressed in: #5908
Came up with a possible fix for the issue, but I'm hitting another issue. Applying changes to the postcss.config.js
file only has effect after restarting the dev server.
I just wanted to know if it was an issue before, so that it will get addressed in another PR and doesn't block the current one.
Any ideas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it was looking at the old code. I'd be fine merging it first, then handle the restart later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it was looking at the old code. I'd be fine merging it first, then handle the restart later.
Sounds good, thanks!
I found another side effect from this PR. There are classes in Tailwind that relies on Autoprefixer to work in all current browsers. One being Background Clip. Tailwind styling that works perfectly fine in Astro 1.9 in dev, doesn't work in the current beta if using the lastest Chrome. It would probably be a good idea to keep autoprefixer enabled in dev, as some Tailwind classes rely on it to work across all browsers. Otherwise it will probably be quite confusing when working in dev if certain parts of Tailwind does not work in popular browsers, like Chrome. |
I think I saw this issue in Discord too. We can definitely add an option to turn on autoprefixer in dev, but I still think it's good to turn it off by default to have good performance. Usually it's expected that developers work in evergreen browsers, but Another option is to turn on |
…tup) that removed autoprefixer in non build modes
That's not true if your project targets any old browsers, you would need to test them when developing, not after building. I think Astro can provide an option for users who want to disable autoprefixer in dev env, but please don't turn that option on by default as it could break things like the issue #5989 |
Please do, but ideally with Autoprefixer on by default. |
Hey, I upgraded from v1.0.0 to v2.6.0 and there was an error regarding this |
Make sure to upgrade all the astro-related dependencies together. |
So the astro update itself happens when adding the official netflify adapter. Is there any command to upgrade all astro required dependencies? |
|
Changes
As discussed in the maintainers chat, the
style.postcss
Astro config can be removed in favour ofvite.css.postcss
. They do the same thing internally, and is only a property used by the tailwind integration.I also disabled autoprefixer in dev. I'm not sure if this was intentional, but enabling it slows down dev a lot so I changed that in the PR too.
Testing
It doesn't seem like there's existing tests for tailwind, but I've tested manually with the
with-tailwindcss
example and it works.Docs
n/a. internal refactor.