Unable to parse the CSS when rendering server-side
See original GitHub issueEnvironment(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:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Don’t enable
babel-plugin-import
and itsoption.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.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.