Skip to content

setting attributeNames to "className": "className" will not output any classnames #294

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

Closed
paperclover opened this issue Dec 17, 2020 · 1 comment

Comments

@paperclover
Copy link

I know it's done on purpose to use styleName over className, but i don't want to use any global classes in this project at all, so i'd like to try to use this configuration in .babelrc. however, when the mapping equals itself, it gets cleared or something.

"babel-plugin-react-css-modules", {
  "attributeNames": {
    "className": "className"
  }
}

Component Code

import 'index.module.css'

export default function Test() {
  return <div className='container'>hi</div>
}

Compiled Code

import './pages/index.module.css';
export default function Test() {
  return <div>hi</div>;
}

as a workaround i can name the props differently ("className": "class") and it works fine (this is compiled output of same component)

import './pages/index.module.css';
export default function Test() {
  return <div class="index-module__container___3Jw5r">hi</div>;
}

i'd like this kind of edge case to at least work, even if it's kind of a bad idea to even allow happen.

@paperclover
Copy link
Author

i tried to fix it myself and from a basic test case it seems to work but it may not work with the advanced use examples this plugin supports. this can be seen in the pr

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

No branches or pull requests

2 participants