Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCSS/CSS Module support #662

Merged
merged 5 commits into from
Jun 7, 2020
Merged

SCSS/CSS Module support #662

merged 5 commits into from
Jun 7, 2020

Conversation

bjackson
Copy link
Contributor

@bjackson bjackson commented Jun 7, 2020

This PR adds SCSS/CSS module support. Usage is as follows:

// Filename: HomePage.module.scss
.hero {
  color: red;
}
// Filename: HomePage.js
import styles from './HomePage.module.scss'

const HomePage = () => (
  <div className={styles.hero}>Hello</div>
)

export default HomePage

The div that contains hello will have the hero class applied to it.

This also adds sourcemap support for SCSS/CSS with or without modules. So in your web inspector, you can view the source for the styles, instead of it saying <style> for the source.
image

Classnames are generated with hashes in production builds, like in the image above. In dev, the names are more descriptive like: .src-pages-HomePage-HomePage-module__heroName--rNGDY. This is based on the recommendations in css-loader's documentation.

Copy link
Contributor

@peterp peterp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

@peterp peterp added this to the next release milestone Jun 7, 2020
@peterp peterp merged commit d27def4 into redwoodjs:master Jun 7, 2020
@brianespinosa
Copy link

brianespinosa commented Jun 9, 2020

Thank you @bjackson this was the last thing I needed to jump in and start playing with Redwood and I did not have the bandwidth to try adding the support myself.

And I can see that this was added today in v0.10.0 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants