create-react-library icon indicating copy to clipboard operation
create-react-library copied to clipboard

Dynamic classname in css file

Open yogesh45 opened this issue 3 years ago • 2 comments

I am adding a scss file for my component

But after compiled in dist/index.css file the classname added inside my scss files get changed

SCSS : .selected{ background-color: blue; color: white; } .blured{ color: #ccc; opacity: 0.5; pointer-events: none; } .header{ width: 100px; }

Index.css ._NBCalender__selected__2iz2b{ background-color: blue; color: white; } ._NBCalender__blured__2dYaJ{ color: #ccc; opacity: 0.5; pointer-events: none; } ._NBCalender-style__selected__tbQ82 { background-color: blue; color: white; }

._NBCalender-style__blured__2f44- { color: #ccc; opacity: 0.5; pointer-events: none; }

._NBCalender-style__header__3kezG { width: 100px; }

Is there any way to fix this

yogesh45 avatar Mar 31 '21 09:03 yogesh45

For some reason microbundle-crl treats *.scss files like modules and does this. Disabling css modules fixes this problem: https://github.com/developit/microbundle#css-and-css-modules

so in your package.json change the scripts to

    "build": "microbundle-crl --no-compress --no-css-modules --format modern,cjs",
    "start": "microbundle-crl watch --no-compress --no-css-modules --format modern,cjs",

sadu avatar May 09 '21 12:05 sadu

For some reason microbundle-crl treats *.scss files like modules and does this. Disabling css modules fixes this problem: https://github.com/developit/microbundle#css-and-css-modules

so in your package.json change the scripts to

    "build": "microbundle-crl --no-compress --no-css-modules --format modern,cjs",
    "start": "microbundle-crl watch --no-compress --no-css-modules --format modern,cjs",

Thank you! This did indeed work. Only problem is that now I can't use modules, so not the ideal solution, but I can make it work. I'm assuming there's no way to use both right?

gabriel-visualthinking avatar Oct 12 '21 16:10 gabriel-visualthinking