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

Unable to use scss files.

Open stefann01 opened this issue 5 years ago • 6 comments

Hello, I don't see anywhere in documentation how can scss files cand be used. Any ideas?

stefann01 avatar Jun 25 '20 10:06 stefann01

import styles from './yourstylesheet.scss' at the top of your package

And then for every className make sure to use styles.yourClass rather than entering the string "yourClass", I think that is just how Rollup is configured.

ShreyKumar avatar Jul 12 '20 20:07 ShreyKumar

I'm currently writing a component library. I need consistent and predictable CSS Class names. This allows consumers of my component library to override CSS styles, or even set SASS variables and build the CSS within their own React Apps.

A "real world" example would be Bootstrap. More specifically, React Bootstrap. Without consistent CSS Class names, it wouldn't be of much use.

Anyone know how we might use SCSS/SASS (node-sass) without creating CSS modules?

UPDATE

I should read the FAQ more often. I hear they have answers to questions that are frequently asked.

The following link shows how you can "opt out" of CSS Modules.

https://github.com/transitive-bullshit/create-react-library/issues/56#issuecomment-630322078

In the event that the link breaks, the author states the following:

In ./package.json, add the following option to both the "start" and "build" scripts (microbundle-crl) and re-run the script:

--css-modules false

Once applied, the styles in ./dist/index.css should have predictable CSS Class names.

robv8r avatar Jul 17 '20 19:07 robv8r

Ah thanks, @robv8r! I've been after the same thing as well

ShreyKumar avatar Jul 17 '20 19:07 ShreyKumar

You can still use scss file as below: import './yourstylesheet.scss' Then in this scss file . Add :global{ ... } to wrap your scss style code .

garryguzy avatar Sep 19 '20 15:09 garryguzy

I am able to load .scss using node-sass and sass-loader as my devDependencies

NishithHM avatar Nov 09 '20 04:11 NishithHM

https://github.com/transitive-bullshit/create-react-library/issues/259

munkk avatar Nov 27 '20 14:11 munkk