Skip to content
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

Vite build Puck V 0.14.0 not showing correct css for dropzones among other classes #408

Open
agustin9998 opened this issue Apr 2, 2024 · 6 comments

Comments

@agustin9998
Copy link

The first thing to appreciate is all of your work on this great library.

I have an application in Vite and when building it, some CSS classes such as the dropzone ones do not get applied correctly. When running in development mode I have no problems at all. This is a screenshot of the Preview component in development mode compared to building the application.

Dev mode:
image

Build:
image

@chrisvxd
Copy link
Member

chrisvxd commented Apr 2, 2024

Thanks @agustin9998! Would you be able to share an example repo that reproduces this issue?

@agustin9998
Copy link
Author

agustin9998 commented Apr 2, 2024

@chrisvxd I will create a demo repo when I have time later today or tomorrow, I was able to fix it though and I think I figured what was going on.

Vite differently from WebPack creates CSS files and imports them via <style> tag via HTML, as the Puck Preview uses an iframe, it is incapable of using this CSS imported via HTML. I installed this library so that it just injects the CSS into JS files when building.

This isn't an ideal solution since I'm handicapping a Vite feature, but I'm okay with it for now.

@chrisvxd
Copy link
Member

chrisvxd commented Apr 2, 2024

Hm that's not ideal. You can always opt out of iframes with iframe={{ enabled: false }} if they're not working for you.

I wonder if this might also help once implemented: #409

@agustin9998
Copy link
Author

@chrisvxd That worked! And it's by far a cleaner solution.

Besides Viewports, I don't see any real advantage of the Iframe right?

Thanks for the solution.

@agustin9998
Copy link
Author

agustin9998 commented Apr 2, 2024

About #409, I like option 2 the most, even though I like specifics on the 3 better, (e.g being able to create a URL for the imported styles an passing them to the Puck component, without creating a style tag). This could be a problem when wanting to import multiple URLs ?

Just my humble thought.

@chrisvxd
Copy link
Member

chrisvxd commented Apr 2, 2024

If you don't need viewports, you might want to use iframes for better style isolation. But if that's not a concern, feel free to disable it!

We suspect the majority of Puck users do want viewport support, so decided to enable it by default.

And thanks for suggestions on #409! I think I'm leaning towards option 2, as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants