Anidetrix / rollup-plugin-styles

🎨 Universal Rollup plugin for styles: PostCSS, Sass, Less, Stylus and more.
https://anidetrix.github.io/rollup-plugin-styles
MIT License
243 stars 43 forks source link

Add localsConvention option to postcss css modules #135

Open vladshcherbin opened 4 years ago

vladshcherbin commented 4 years ago

It would be great to have localsConvention option, it's useful when you have css file with dashes in classes:

.field-error {
  color: red;
}

Using this option you can import style classes in js this way:

import css from './styles.scss'

console.log(css.fieldError)

// instead of 

console.log(css['field-error'])

Seems like currently there is no way to do this. I've checked source code and it seems postcss-modules package is not used inside so this option can't be passed 😞

dfvalero commented 3 years ago

Hi @vladshcherbin , I added this in my rollup.config plugins and it worked:

postcss({
  modules: {
    localsConvention: 'camelCase',
  },
}),