Skip to content

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

Closed
@paperclover

Description

@paperclover

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions