Blur filters don't work in production build
See original GitHub issueWhat version of Tailwind CSS are you using?
2.1.4
What build tool (or framework if it abstracts the build tool) are you using?
laravel mix 6.0.19
What version of Node.js are you using?
16.0.0
What browser are you using?
Chrome
What operating system are you using?
maxOS
Reproduction repository
https://github.com/denjaland/tailwind-bug-repro
Describe your issue
We have a div that has applied styles filter blur-3xl
Renders quite beautifully on a dev build, but on the production build we have a hideous result:
Dev result:
Production result:
Not really what we are looking for. So I checked the compiled CSS, and this is what I see.
On dev build, I have these styles:
.filter {
filter: var(--tw-filter);
}
.blur-3xl {
--tw-blur: blur(64px);
filter: var(--tw-filter);
}
The production build however has this as a result:
.blur-3xl, .filter {
filter: var(--tw-filter);
}
.blur-3xl {
--tw-blur: blur(64px);
}
which, in Chrome at least, doesn’t render correctly.
I’m not sure it’s a bug, but I wouldn’t even know where to begin checking to see what’s causing the issue if it isn’t in the compiler.
I have tested it in regular
as well as jit
mode with the same result.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Backdrop filter not working after build #7044 - GitHub
After building, the backdrop filter blur isn't working, but the css is there. Not tested with other filters.
Read more >Why blur filter does not work in this example - Stack Overflow
Blur actually blurs content inside that object. It doesn't blur everything beneath the div. For example, if you add the image inside of...
Read more >Tips for Using the Blur Filters in Photoshop
Photoshop's blur filters handy for creating blur in post-production to add a shallow depth of field and other effects. Here are some tips...
Read more >Photoshop Elements Blur filters - Adobe Support
The Surface Blur filter blurs an image while preserving edges. This filter is useful for creating special effects and for removing noise and ......
Read more >overflow hidden doesn't work anymore when blur is applied
I've attempted to make a reproduction for this issue, with little success. The closest I could come is that a blur filter itself...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yeah GitHub repo would be perfect thank you! Can figure this out for sure 👍🏻
Hey @denjaland! Tailwind makes heavy use of CSS custom properties (variables), and sometimes an empty value (actually a single space) is used. While this is perfectly valid, some minifiers may handle it incorrectly and break the CSS, so we use comments to “trick” minifiers into producing working output, for example:
Now the problem you are running into is happening because you are using Mix’s
minify()
, which usesclean-css
under the hood. Unfortunately, even with our “tricks”clean-css
seems to be producing broken output.Fortunately in this case there is a simple fix, which is to remove
minify()
completely, sincepostCss()
minifies its output in production anyway. This minification usescssnano
which handles the empty values just fine. Here’s a pull request with the changes required to fix your reproduction: https://github.com/denjaland/tailwind-bug-repro/pull/1Hope that helps!