I appreciate your time and help. I spent hours trying to figure this out can't seem to get to the bottom of it.
I have this react component:
import styles from './style.scss';
class ButtonComponent extends React.Component {
render() {
return (
<div className={styles.bunny}>
hello world
</div>
);
}
}
and scss file:
.bunny {
display: block;
margin-top:50px;
margin-bottom:55px;
background-color: blue;
}
When I load up my html, the div has no classname when I expect it to be <div class="bunny">
When I put the class name in the react component literally like this:
<div className="bunny">
then I can see the className in the browser.
What am I doing wrong?
Thank you so much in advance.
css-loader
inside webpack? – Joellyn{ // Preprocess our own .css files // This is the place to add your own loaders (e.g. sass/less etc.) // for a list of loaders, see https://webpack.js.org/loaders/#styling test: /\.(s*)css$/, exclude: /node_modules/, use: ['style-loader', 'css-loader', 'sass-loader'], },
Not sure if this helps, can you be more specific? – Preconcertimport './style.scss'
and then use your classes as strings:<div className="bunny">
. Of course your html file will need to link the css file too. It's more like tellling webpack: "Hey webpack, this component uses classes from this sass file so include it in my bundle." – Ginemodules
property offered by webpack'scss-loader
in order to used modularized css where you can import the style sheet and reference the classes like object properties – Joellyn