Css-loader: Empty style got undefined

Created on 23 Apr 2016  路  5Comments  路  Source: webpack-contrib/css-loader

// styles.scss
.example {
}
render () {
  return <div className={styles.example}></div>
}

When .example is empty, styles.example will become undefined.

How to avoid this? since I don't need to set styles to .example right now, but have to override its styles somewhere else, so I need to get a dedicated class name.

Also reported in https://github.com/css-modules/css-modules/issues/140

Most helpful comment

If you follow the chain of issues from the CSS Modules one, it turns out this is actually to do with SASS removing empty styles, which can be overridden with a comment - see https://github.com/sass/sass/issues/2069.

This is working fine for me if I use the mixin in that issue.

All 5 comments

What should it generate? I wonder if this a spec issue.

It should be Card__example if the localIdentName=[name]__[local], but got undefined

I think empty string would be fault tolerant, but depends on whether you want to strip unstyled classes or not

I want to keep the className because I want to override it somewhere else.

If you follow the chain of issues from the CSS Modules one, it turns out this is actually to do with SASS removing empty styles, which can be overridden with a comment - see https://github.com/sass/sass/issues/2069.

This is working fine for me if I use the mixin in that issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

callmez picture callmez  路  4Comments

jonathanong picture jonathanong  路  3Comments

heldrida picture heldrida  路  4Comments

felipecarrillo100 picture felipecarrillo100  路  3Comments

dmiller9911 picture dmiller9911  路  3Comments