13

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.

Luboš Turek
  • 6,273
  • 9
  • 40
  • 50
user2309185
  • 388
  • 1
  • 4
  • 10

2 Answers2

7

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

maletor
  • 7,072
  • 7
  • 42
  • 63
  • 1
    This configuration option is noted in the documentation here: http://webpack.github.io/docs/configuration.html#target – rmarscher May 11 '15 at 20:03
2

You could use require.extensions like this:

require.extensions['.css'] = function() {return null}
Nick Dima
  • 1,587
  • 2
  • 18
  • 36