question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to parse the CSS when rendering server-side

See original GitHub issue

Environment(required)

  • antd version: 2.6.4
  • OS and its version: Mac OS 10.12
  • Browser and its version: Webpack issue

What did you do? Please provide steps to re-produce your problem.

I tried to use babel-import-plugin to use the modular version of antd when rendering the client server side.

What do you expected?

That it works as normal.

What happen?

I followed the same structure as this repo (https://github.com/afc163/react-boilerplate) that you made to solve another issue. I am using the same boilerplate, but with server side rendering added in too. When I use the import plugin to minify my antd imports, I get this error when starting up the server:

/Users/Declan/coding/tmp/react-boilerplate/node_modules/antd/lib/style/index.css:10
html {
     ^
SyntaxError: Unexpected token {

If I don’t add the import plugin, it works with server side rendering, but it imports the entire library rather than just the modules I want. I have also tried copying the css-loader and style-loader setup from here to see if it’s an issue with being unable to load the .css file, but that didn’t work.

Re-producible online demo

https://github.com/declanelcocks/react-redux-boilerplate and run yarn start after installing the dependencies. You can check this file where I am trying to setup the import plugin.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
afc163commented, Jan 25, 2017

Don’t enable babel-plugin-import and its option.style in server side cause it is not necessary. And it is not able to import css file in server either.

Keep babel-plugin-import enable only in browser side.

0reactions
lock[bot]commented, May 2, 2018

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to render html tags that were returned by the server ...
In my React project, I make an API call to the server which returns some HTML that I have to render. Below is...
Read more >
How does the browser work when rendering a web page? For ...
Begin constructing the DOM by parsing HTML (1. parsing); Request CSS and JS resources (The rendering will be blocked); Parse CSS and build ......
Read more >
SSR - Server-Side Rendering - LinkedIn
So even though your browser has your HTML, it can't render the website until its corresponding CSS has finished parsing.
Read more >
react-hydration-error - Next.js
When css-in-js libraries are not set up for pre-rendering (SSR/SSG) it will often lead to a hydration mismatch. In general this means the...
Read more >
Server-Side Rendering (SSR) - Vue.js
Vue.js is a framework for building client-side applications. ... external libraries may need special treatment to be able to run in a server-rendered...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found