Gatsby StaticImage does not respect TailwindCSS responsive modifiers in the production build. #33565
-
Preliminary Checks
DescriptionFollowing code work as expected in dev mode but Gatsby StaticImage do not respect TailwindCSS responsive modifiers in the production build.
Reproduction Linkhttps://github.com/kaushalyap/gatsby-tailwind-bug Steps to Reproduce1.Clone the repo & Expected ResultProduction build UI should be consistent with the dev build UI, which means production build should respond to tailwindcss responsive modifiers as in the dev build Actual ResultIn production build, both images are shown regardless of screen size EnvironmentSystem:
OS: Linux 5.14 Fedora Linux 35 (Workstation Edition)
CPU: (8) x64 Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
Shell: 5.8 - /usr/bin/zsh
Binaries:
Node: 14.17.2 - /tmp/fnm_multishells/49671_1634538470105/bin/node
Yarn: 1.22.15 - /usr/bin/yarn
npm: 7.20.3 - /tmp/fnm_multishells/49671_1634538470105/bin/npm
Languages:
Python: 3.10.0 - /usr/bin/python
Browsers:
Firefox: 93.0
npmPackages:
gatsby: ^3.14.2 => 3.14.3
gatsby-plugin-image: ^1.14.1 => 1.14.1
gatsby-plugin-postcss: ^4.14.0 => 4.14.0
gatsby-plugin-sharp: ^3.14.1 => 3.14.1
gatsby-source-filesystem: ^3.14.0 => 3.14.0
gatsby-transformer-sharp: ^3.14.0 => 3.14.0 Config FlagsNothing |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
This happens due to CSS specificity. The style for Use |
Beta Was this translation helpful? Give feedback.
This happens due to CSS specificity. The style for
.gatsby-image-wrapper-constrained
is for performance reasons in a<style>
tag in the<head>
and thus has a higher specificity than the CSS from another file (Tailwind). So it overwrites Tailwind for thedisplay
property.Use
!important
and it'll work.