-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
Minified CSS output #10068
Comments
The Next.js example aims to be as simple as possible. We don't minify the output CSS. |
@oliviertassinari, this works for next.js 5, but I can't for the life of me figure out why this doesn't work for next.js 6. The problem seems to be cssnano: I was able to work around this by using postcss-csso instead. |
@virzak I couldn't upgrade to Next.js v6 yet because of Babel. I have no clue. |
@oliviertassinari This is the error I was getting:
Repeating this: https://github.com/mui-org/material-ui/blob/v1-beta/next.config.js#L32-L34 made it work. Thank you!!! I guess knowing Webpack really well is a must. |
I come from "isomorphic-style-loader" world where the CSS per component is autoprefixed/cssnanod etc at build time and injected into the page as and when required at runtime. The proposed solution here with CSSinJS is to do this minifcation/prefixing at runtime making something like cssnano a dependency rather than a devdepdencency. Have I understood correctly? It seems a little strange to me vs the way isomorphic-style-loader works. I ended up here because I haven't found a nextjs website that has an example of minified css when using cssinjs. One example I did find (above) is for static generated sites. |
@samkelleher Your analysis is correct. It's an area of improvement. I'm wondering how the alternative CSS-in-JS solutions handle the problem. cc @kof. |
Isn't the CSS for the client only generated at runtime? Minification wouldn't add much value in that case as far as I can tell. This is especially true for dynamic styles. You could make an argument for static CSS that does not depend on a theme but this would require something like |
I think JSS should remove whitespaces in production. More advanced minification is out of scope. |
I think the biggest minification one could do is rendering atomic css. I always wanted to try that out for SSR. |
Hello :) Now I have:
Any link to example / documentation would be appreciated. thx in advance for any help. |
You def. shouldn't have 735 lines of critical css from 1 line of your app. |
In the short term I wrapped cssnano in the HtmlDocument to minify the css being injected into the page at runtime. After this, I moved away from NextJS and did this minification during webpack build. |
On the Gatsby side, the plugin minify and prefix at build time. |
This comment has been minimized.
This comment has been minimized.
Is this actually done? I don't see any documentation update. @oliviertassinari |
@modbender Which problem are you trying to solve? I assume you are doing server-side rendering and hosting the pages on a CDN. If not, ignore this matter, minification harms performance. |
@oliviertassinari I was talking about |
@modbender By "harms performance", I meant that if it's done at runtime for each request, sending the CSS non-minified will be faster overall. On the other hand, caching the CSS minified can help a bit. |
@oliviertassinari Oh, sorry I don't know much about caching CSS so could you point me to some doc to do it, i'm using nextjs, and with nextjs I think it will take time only while running build right? |
When I am using MUI with next.js the styles that are generated on the server are not minified.
Even the nextjs example in the repo is not minifying CSS output when it is built for production.
The docs site actually has minified CSS, but I couldn't figure out how it is doing it.
Anyone knows how to make MUI/JSS to minify CSS output?
The text was updated successfully, but these errors were encountered: