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

Export plain SCSS files

Open bohdanbirdie opened this issue 4 years ago • 1 comments

Hi there!

I'm using the SCSS in my components library, and willing to export it with the build so I can reuse the SCCS in the main app Is it possible? I have been looking into the microbundle and create-react-library docs, but no success

bohdanbirdie avatar Jun 03 '20 13:06 bohdanbirdie

Ok, it is possible by setting two props in package.json

//....
"style": "src/scss/core.scss",
//....
"files": [
    "dist",
    "src/scss" // add this
  ],
//....

Now the src/scss folder with all files will be a part of the package version that is installed into node_modules

image

Then in the project, where you want to import SCSS do it with

@import "pacakge-name/src/scss/core.scss"; // in my particular case

For Create React App no need to add ~ prefix for package SCSS import

Thanks for the great tool, @transitive-bullshit!

bohdanbirdie avatar Jun 04 '20 20:06 bohdanbirdie