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

[v2] css modules class names with dashes / camelCased locals #5458

Closed
pieh opened this issue May 17, 2018 · 10 comments
Closed

[v2] css modules class names with dashes / camelCased locals #5458

pieh opened this issue May 17, 2018 · 10 comments
Assignees
Labels
type: question or discussion Issue discussing or asking a question about Gatsby

Comments

@pieh
Copy link
Contributor

pieh commented May 17, 2018

Currently in v2 css modules there is undocumented breaking change - dashed class names will be camelCased (

camelCase: `dashesOnly`,
)

Omitting that setting or setting it to false will result in same behaviour as in v1. Setting it to true or 'dashes' would return both dashed and camelCased version of it - might be worth using that?

@jquense
Copy link
Contributor

jquense commented May 17, 2018

dashes is the most accepting setting, but it leads to larger bundles since most css classes are duplicated in the locals export (the camel and dash cases). I went with the dashesOnly setting a bit out of personal convenience, but i do think it's probably the community wide "best practice" (for lack of a better word) and fairly uncontroversial, saving on bytes while also allowing idiomatic casing for css and js

@pieh
Copy link
Contributor Author

pieh commented May 17, 2018

It makes sense - in this case we would "just" need to update the migration guide so it's documented.

I'll leave this issue opened just to get more input on the matter from other folks.

@KyleAMathews
Copy link
Contributor

Yeah, there was a few discussions for this change in the past:

@m-allanson m-allanson added the type: question or discussion Issue discussing or asking a question about Gatsby label May 18, 2018
@pieh
Copy link
Contributor Author

pieh commented Aug 2, 2018

I was just thinking about it - would it make sense to revert to v1 default and create plugin to easily overwrite css module rule options? Something that walks webpack config object rules and if loader is css-loader and options.modules === true replace/merge options with what user specify?

@m-allanson
Copy link
Contributor

Maybe let's go the other way around? dashesOnly seems like a good option and v2 is the time to make breaking changes. I'll add a section to the migration guide.

@dustinhorton
Copy link
Contributor

@pieh did you happen to write something to allow for v1 behavior? have multiple projects where this change is causing some pain.

pieh pushed a commit that referenced this issue Nov 1, 2018
v2 changed how dashes/hyphens in class names handled by css modules were treated: #5458. This was burdensome as it required changing all `className`s that utilized dashes.

This allows overriding that change, almost entirely by copying prior art from @yeskunall & @pieh (#9237).
gpetrioli pushed a commit to gpetrioli/gatsby that referenced this issue Jan 22, 2019
v2 changed how dashes/hyphens in class names handled by css modules were treated: gatsbyjs#5458. This was burdensome as it required changing all `className`s that utilized dashes.

This allows overriding that change, almost entirely by copying prior art from @yeskunall & @pieh (gatsbyjs#9237).
@HamidReazaNikoonia
Copy link

what about pt-5 , pt5 not working

@dustinhorton
Copy link
Contributor

@HamidReazaNikoonia what part 5?

@acalderongarcia
Copy link

@HamidReazaNikoonia what part 5?

pt-5 padding-top

@dustinhorton
Copy link
Contributor

@acalderongarcia have you added this to your gatsby-config.js?

module.exports = {
  plugins: [
    {
      resolve: 'gatsby-plugin-sass',
      options: {
        cssLoaderOptions: {
          camelCase: false,
        },
      },
    },
  ],
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question or discussion Issue discussing or asking a question about Gatsby
Projects
None yet
Development

No branches or pull requests

7 participants