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.

1
  • 1
    did you have a chance to workaround this? Commented Mar 26, 2015 at 15:05

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

1 Comment

This configuration option is noted in the documentation here: webpack.github.io/docs/configuration.html#target
2

You could use require.extensions like this:

require.extensions['.css'] = function() {return null}

1 Comment

great job, woks for me!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.