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

Add support for CSS modules #295

Merged
merged 3 commits into from
Jul 6, 2016

Conversation

jakubrohleder
Copy link
Contributor

With this PR all .module.(css|less|scss|sass) files are treated as CSS modules.

Resolves #193


[Css modules](https://github.com/css-modules/css-modules) are support by default for all files with `.module.(css|less|scss|sass)` extension.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be "CSS Modules" here plus in the header.

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps add examples of two css files where one (main.css) wouldn't use CSS Modules and another (my-awesome-component.module.css) would be.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

By example, you mean to add example to gatsby-starter-default (or other starter) or to readme?

Copy link
Contributor

Choose a reason for hiding this comment

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

Well that would be great too (adding to the starter) :-) but I meant here to add a simple example like:

// Uses CSS Modules
import './my-component.module.css'

// Doesn't use CSS Modules
import './main.css'

@KyleAMathews
Copy link
Contributor

Looking great other than the few minor tweaks!

@KyleAMathews
Copy link
Contributor

@jakubrohleder if you have a bit of time soon to make the last few tweaks, that'd be great!

@jakubrohleder
Copy link
Contributor Author

@KyleAMathews I just have really busy time, but I'll finish this issue soon. Sorry for the delay.

@KyleAMathews
Copy link
Contributor

Great to hear! And no worries about being busy. I only asked as the remaining changes are simple enough that if you weren't able to get to it soon, I'd just tidy it up and release it myself.

@KyleAMathews
Copy link
Contributor

Looking great! Will merge and publish this soon. Could you merge the latest changes from master before then?

@jakubrohleder
Copy link
Contributor Author

@KyleAMathews I've just realised that css modules are important for build-javascript step as well.

Without them styles objects in the bundle.js are empty, and when the JS is loaded page becomes unstyled.

What a tricky PR...

@KyleAMathews
Copy link
Contributor

Hmmm you're right. Bit of a mind bender webpack eh? :-)

@NogsMPLS
Copy link
Contributor

Dunno if this helps, but for my component library to solve a similar problem I used: https://github.com/michalkvasnicak/babel-plugin-css-modules-transform

@KyleAMathews KyleAMathews merged commit 5b101be into gatsbyjs:master Jul 6, 2016
@KyleAMathews
Copy link
Contributor

Merged and added the css modules to the build-js step! Looks like things are working great! Will make new release soon. Thanks!!!

Added a css modules example to the default starter. See gatsbyjs/gatsby-starter-default@5e22fa2 and http://gatsbyjs.github.io/gatsby-starter-default/css-modules/

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