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 custom css modules name patterns #180

Merged
merged 4 commits into from May 20, 2022

Conversation

devongovett
Copy link
Member

Closes #156.

This adds support for custom patterns for generating names in css modules. Using cssModules: true continues to use the same default pattern as before, but you can also now set it to a config object:

{
  cssModules: {
    pattern: 'library-[name]-[hash]-[local]
  }
}

The currently supported segments are:

  • [name] - the base name of the file name being transformed, without the extension
  • [hash] - a hash of the full file path
  • [local] - the original class name

We could add more if needed as well. The pattern is parsed ahead of time and interpreted when writing out class names. Hopefully this solves the majority of use cases. We could add a JS callback for this as well, but it would add a lot of performance overhead so I would like to avoid it if possible.

@devongovett devongovett marked this pull request as ready for review May 20, 2022 14:34
@devongovett devongovett merged commit c7a59e1 into master May 20, 2022
@devongovett devongovett deleted the cssmodules-config branch May 20, 2022 14:39
@joelmoss
Copy link
Contributor

Was this new functionality added to the rust CLI?

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.

[Feature Request] Support generateScopedName config like postcss-modules
2 participants