jonasbuntinx / next-purescript-example

Simple example app using Next.js with Purescript
https://next-purescript-example.netlify.app/
MIT License
66 stars 10 forks source link

TailwindCSS with SSR without JavaScript #8

Closed alaendle closed 2 years ago

alaendle commented 2 years ago

First let me thank you for this great example 🎉 I used it to play around with SSR. However after disabling JS in the browser to take a real look on the pure server-side-rendered site I noticed that because of the JS imports of the CSS the CSS isn't included in the pre-rendered output.

Tried to realize a solution like discussed here https://github.com/vercel/next.js/discussions/12868#discussioncomment-292294; but I wasn't able to complete it and I'm also I'm unsure is this is the right way. So maybe you could give a point to the right direction? Is there a way to tell next.js to include the CSS; or do we really need a dirty workaround here?

alaendle commented 2 years ago

Seems only to be an issue while using npm run dev:serve - npm run start seems to do further optimization that lead to css references. Sorry, if this is clear to the experienced next.jsuser; I'm a js newbie 😒 .

jonasbuntinx commented 2 years ago

Interesting. Thanks, I'll look into this.

alaendle commented 2 years ago

Seems to be a general next.js manner - at least https://github.com/vercel/next.js/tree/canary/examples/with-tailwindcss exposes the same odd behavior. Personally I become skeptical if behavior differs between development and production builds differ so much. So far I haven't recorded an issue at next.js because I have the feeling that the circumstance should be known there and I don't really know how to describe the problem correctly. In any case, it's not your project 🥳

alaendle commented 2 years ago

https://nextjs.org/docs/basic-features/built-in-css-support#does-it-work-with-javascript-disabled