-
Notifications
You must be signed in to change notification settings - Fork 4.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
Cannot use HTML style tag with Vite to apply a theme #16036
Comments
At best it would be if |
Going to add support for this in the next patch release, thanks for your report 👍 |
Can you also test against text/tailwindcss? I think it behaves different in Vite as it will not be picked by it |
That works pretty well, thank you! Just had to remove CDN and text/tailwindcss on post process but now we have a nice preview through CDN with all functionality and a reduced bundle in production! {
name: "vite-plugin-remove-tailwindcss-cdn",
apply: "build",
transformIndexHtml: {
order: "post",
handler(html) {
const nextHtml = html.replace(
/<script src=.*?tailwindcss.*?script>/i,
"",
);
return nextHtml;
},
},
},
{
name: "vite-plugin-remove-text-tailwindcss",
apply: "build",
transformIndexHtml: {
order: "post",
handler(html) {
const nextHtml = html.replace(/<style type=.*?>/i, "<style>");
return nextHtml;
},
},
}, |
What version of Tailwind CSS are you using?
v4.0.1
What build tool (or framework if it abstracts the build tool) are you using?
Latest Vite with autoprefixer
What version of Node.js are you using?
NodeJS v22.10.0
What browser are you using?
Brave
What operating system are you using?
macOS
Reproduction URL
Vite config
Describe your issue
We have single HTML files which are report templates in a facility for analysis reportings that are styled with tailwindcss. These are later processed by Vite to reduce their size and to process tailwindcss classes. We aren't able to support external CSS or JS here since these templates are generated by another tool which has its own syntax and templates. When processing these HTML with Vite tailwindcss seems to ignore inline CSS even with
text/tailwindcss
. Using the CDN works fine, but our reports need to work offline (companies that size do not allow these machines to have internet access on pruporse ofc). The reason we use the style tag is because that way we can provided a versioned theme to each report template and do not need to touch our template files which consist of many smaller modules that we do not want to touch that often and because each customer can have its own styled theme or custom styles for individuallity.The text was updated successfully, but these errors were encountered: