Skip to content

loadable-components example requires JS enabled to display CSS in development #1895

Open
@thomasjm

Description

@thomasjm

🐛 Bug report

Current Behavior

Normally I like to debug server-side rendering by disabling Javascript in my browser and loading the page to see how it looks.

Unfortunately, this isn't working with the examples/with-loadable-components example when I use CSS modules like Tachyons, because the CSS goes into the main client.js file in some code connected to css_loader. Thus, rendering the page without JS enabled doesn't accurately reflect what a server-side render should look like.

In production builds on the other hand, we get <style> tags inserted into the page.

Expected behavior

All CSS should always be inserted into the server-rendered page in a non-JS-requiring way, including in development.

Reproducible example

https://github.com/thomasjm/razzle/tree/loadable-components-css/examples/with-loadable-components

Repro is as follows:

git clone [email protected]:thomasjm/razzle.git --branch loadable-components-css
cd razzle/examples/with-loadable-components

npm install
npm run build
npm run start

# Open localhost:3000 in browser
# Notice that the heading has a red color due to a CSS rule from Tachyons

# Now, open browser dev tools, disable Javascript, and refresh the page
# You should see that the heading isn't red, because the CSS isn't there anymore.

Suggested solution(s)

Perhaps don't use the Webpack CSS loader in development? Not sure what the implications of that would be.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions