Basic Style.css file React-starter app


#1

Hi Everyone!

I had attempted to fork the react-starter app to play around with, however, I’m running into issues with getting my style.css file to take effect. I installed in the css, css-loader, style-loader, react-css-loader into the package.json file and tried loading .css into the webpack file. I can’t figure out where to start looking for documentation/steps on getting this thing started. Does anyone know where I should start?

My project is here:
https://voracious-oil.glitch.me

Thanks,

Allan


#2

To make CSS modules work with Webpack you have to include the css in the component(s) you want to style and include it in your loader settings. The latter part you’ve already done. So move style.css in to the app directory and reference it in HelloWorld.jsx for example using const styles = require('../style.css');. You only need the css-loader and style-loader dependencies.

See https://glitch.com/edit/#!/billowy-flavor for a working example.


#3

Thank you for explaining!! :slight_smile: