My React component index.js
contains styling in style.css
.
I am looking to share this component on npm
, but I am unsure of how to simplify the process for other developers to use the styling.
After exploring different options, I have come across three approaches:
- Utilize
require('./style.css')
and assume users will have a bundling solution (e.g.webpack
,rollup
). However, I am hesitant about this method as it restricts users to a specific approach to utilize my component. - Instruct users to import the style with
. Yet, I am not fond of this solution because it requires users to modify their HTML instead of simply including the React component where they desire.<link rel="stylesheet" href="node_modules/package/style.css" />
- Embed the CSS within the component itself using a plugin like react-jss. Unfortunately, this is not suitable for me as my component's styling involves numerous SCSS files.
None of these solutions align with my requirements and make it cumbersome for others to utilize my component. How can I distribute the component in a user-friendly manner?