I'm using React for my components, and in order to package up the styles with my components, I'm requiring them in as per the documented webpack method:
require('./style.css');
But when I try to render on the server, node-jsx throws an error when it attempts to transform the css. Is there another way of transforming the jsx which won't break on css? I'd rather not break the styles out into their own pipeline as that would defeat the advantage of webpack packaging components up nicely.
-
1did you have a chance to workaround this?Kosmetika– Kosmetika2015-03-26 15:05:13 +00:00Commented Mar 26, 2015 at 15:05
Add a comment
|
2 Answers
This can be solved setting webpack's "target" configuration to "node".
This simple example app should explain it clearly.
https://github.com/webpack/react-webpack-server-side-example/blob/master/webpack.config.js
1 Comment
rmarscher
This configuration option is noted in the documentation here: webpack.github.io/docs/configuration.html#target
You could use require.extensions like this:
require.extensions['.css'] = function() {return null}
1 Comment
Jess
great job, woks for me!