ShakaCode | ShakaCode Blog | Rails On Maui Blog | Rails | ReactJs | JavaScript | Webpack | Productivity |

SCSS Modules with react on rails and webpacker


#1

Hi.
I have Rails 4.2. I installed react on rails and webpacker according to this instuction https://github.com/shakacode/react_on_rails#getting-started-with-an-existing-rails-app.
So I have folder ‘packs’ with hello-world-bundle.js and folder ‘bundles’ with HelloWorld component.
I added hello.module.scss file near HelloWorld.jsx in HelloWorld/components folder. And then I do import scss file in HelloWorld.jsx:

import styles from ‘./hello’

and then add className={styles.hello}. I have selector ‘.hello’.

I didn’t configure any webpack configs. All by default. But when I start rails server then scss file not load. What am I doing wrong?
How can I use scss modules with react on rails and webpacker?


#2

Take a look at this configuration: https://github.com/shakacode/react-webpack-rails-tutorial

I’m not sure what the setup is with the default rails/webpacker setup for “CSS Modules” which is what you are trying to do.