-
Notifications
You must be signed in to change notification settings - Fork 50
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
Not working with react, tailwindcss production setup #70
Comments
Tried the older versions this morning and |
@dreamboyx1.... I'm new to using this polyfill, but I spent ~12+ hours debugging my deployment issue to a complex environment that I don't totally control; lots of large style files and such. It sounds like things are working intermittingly for you just as they were for me. It turns out the old school hack of using an image to attempt to detect when the transpiled styles / data blob has loaded failed ~half the time or more. When In my production environment there are many style files on the page that don't need to be transpiled / updated; also potentially size of style file could cause things to fail with the image load hack. Changing to using the I removed this: and handled loading the transpiled data blob similar to this: const loadCallback = () => {
styleSheet.refresh();
node.removeEventListener('load', loadCallback);
}
node.addEventListener('load', loadCallback);
node.href = URL.createObjectURL(blob); In my fork I fix the loading hack and don't replace style files that don't have container queries. This was quite the challenge to debug due to the intermittent nature of the problem in my production environment. Hopefully that helps or at least gives something to try. |
Another issue I encountered on Firefox is that after the style files are processed, and link hrefs are replaced with blobs, images (e.g. While my issue is not relevant to the current one discussed, my solution was similar to @typhonrt's: processing only the styles containing container queries. In my case, I ended up separating container queries in separate files from regular CSS. Maybe this (extracting only the container queries into a new |
The fix worked for me. Thanks a lot, @typhonrt! |
I've been spending way to many hours trying to get this plugin to work with our react, tailwind app. I was really excited about using it, but alas it is not going well. I've managed to put together a minimal reproducible Create React App (CRA) package here.
https://github.com/dreamboyx1/container-query-polyfill-example
Steps are:
npm install
npm run prod
This should start a static server using serve. You should then point your browser to: http://localhost:3000/
It will work ok running in development mode. That is, it will work as expected. It just does not work with a production build. So, I think some tailwind optimization or tree shaking is stomping on things. Not quite clear, yet. However, since this setup is super common, it would be great if this worked or at least there were some workaround to get it all working together.
I may dig in more, but I've more than exhausted my time box for now. Hopefully some other folks will be interested as well. Or maybe someone will tell me I'm an idiot and doing it wrong, which is ok and would not be the first time :).
The text was updated successfully, but these errors were encountered: