react-redux-universal-hot-example icon indicating copy to clipboard operation
react-redux-universal-hot-example copied to clipboard

Require style in render() or at top of document.

Open RuudBurger opened this issue 8 years ago • 4 comments

Hi guys, I'm wondering if anyone can help me with a question about the (s)css-loader used? The const styles = require('./xxx.scss'); is always inside the render(). And I'm wondering why. Because the classnames generated don't change when calling the module multiple times.

What are the advantages or disadvantage of putting the require at the top of the document instead of in the render function.

RuudBurger avatar Apr 12 '16 21:04 RuudBurger

In fact, you can put const styles = require('./xxx.scss'); after import xxx from 'xx' lines. I think the only advantage of using require in render() is: just convenient.

tearsofphoenix avatar Apr 13 '16 02:04 tearsofphoenix

By the way, any difference between import styles from './xxx.css' and const styles = require('./xxx.css')?

Fouppy avatar Apr 13 '16 08:04 Fouppy

I'm pretty sure there was a reason regarding webpack-isomorphic-tools. Either something related to writing the webpack-assets.json or the hot reloading.

trueter avatar Apr 13 '16 19:04 trueter

Curious about this too. Trying to figure out if this is a convention I should be using in other projects. @erikras looks like you first did this? https://github.com/erikras/react-redux-universal-hot-example/commit/3f12085bf832a5b0d1b6f6be1d12c8ef262ed786#diff-ce1c05c91099707f867faa02837d5756R40

AndrewRayCode avatar Jan 14 '17 02:01 AndrewRayCode