-
Notifications
You must be signed in to change notification settings - Fork 20
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
Setup with MUI #79
Comments
I should also mention that those errors only happen in production (but I guess that's because of the |
I am hitting a similar roadblock here, in my case it's related to the styles that I import in my
|
Any updates here on being able to use MUI without |
We are facing similar issues. Unfortunately I do not have a complete solution. I can however point out that the issue that has to do with Google Fonts that's mentioned in the first message can be rectified with the example in the repo for using Google Fonts. Likely the styles imported from cdn.jsdelivr.net are also an issue if not adjusted. I attempted to take some patterns from the e2e example and as I've progressed in an explorative manner, I can't list in detail all the steps I took. In general it seems that a way to debug these issues is to try and find the inline styles that cause these issues. It may be that some cases don't directly relate to the interop of MUI and this library, but instead are their own niche cases that circumvent the MUI's CSS-in-JS implementation. For instance in our case one problem scenario came about due to a 3rd party library that we were using. It included its own inline styles which were not hashed at any point because they are only loaded in the client once they are needed. I could find out that these styles were the issue by navigating to the "source file" through the error log and adding a breakpoint that allowed me to inspect what CSS created an error when it was added into the DOM. As far as I know, some of these files you just have to manually pull into the For now I still haven't been able to resolve all cases. But as far as I can see, they tend to relate to how 3rd party libraries include css in the DOM. If you import a css file with However, I couldn't find a good way to extract the CSS that next injects to the head for 3rd party apps (as talked about here https://nextjs.org/docs/pages/building-your-application/styling/css-modules#import-styles-from-node_modules). Next may optimise the css files, add source maps and whatnot. These changes result in changes to the text content which in turn result in changes to the created hash. I would need to get a representation of the contents of the style tag that matches with what Next will inject in the client once the code is required in order to get the correct hash. One workaround I could come up with was to not load this CSS as needed, but instead always load it by including it in the Take this next bit with a grain of salt as I couldn't find a source that addressed this issue specifically. One thing that may cause confusion is that CSP has different "strictnesses". Some contexts refer to hashes and nonces as "strict" CSP whereas CSPs that contain safelists are "safelist" CSPs ( It's not incorrect per se to have these mix matched directives. In essence it can be looked as a backwards compatibility feature. One could in theory provide a safelist for older browsers and nonces and hashes for newer ones. |
First of all thanks for the great library! ❤️
I'm currently trying to make this work in a Next project using MUI and I've been using the discussion in #50 as a guide (although it seems like the OP did use
style-src: unsafe-inline
and I'm trying to avoid that if possible).This is what I have so far (the source code is here):
Unfortunately, I'm still having issues (you can visit the site and open the dev tools):
That error comes from the Google fonts, but I also have errors like these, which pop up when navigating to the "New mikro" page:
I'm stuck now and don't really know what I'm missing :( I also tried following the setup from the e2e example but it resulted in the same errors.
Thanks in advance for your help!
The text was updated successfully, but these errors were encountered: