Answer the question
In order to leave comments, you need to log in
What is the best way to include styles in redistributables?
Good day,
The other day I was going to publish several of my React components in Open Source on npm and then I asked myself the question - how best to arrange the connection of styles. There are several options, which one would be best for you?
First. Connect css to the source of my component.
Plus. In this case, the person who uses my component will only need to connect the component itself.
Minus. To change the styles to their custom ones, the person who downloaded my component will need to either change the source code or override my styles.
my component
import "../styles/open-source-component.css";
export default class OpenSourceComponent
import OpenSourceComponent from "somelib";
export default class OpenSourceComponent
import OpenSourceComponent from "somelib";
import "../noe_modules/somelib/styles/open-source-component.css";
Answer the question
In order to leave comments, you need to log in
The first option is not bad, it is used, for example: datepicker , react-select libraries.
React-virtualized , for example, allows you to include styles using: import 'react-virtualized/styles.css'
(and you don’t need to write the path from node_modules), I think if you figure out how they did it, this will be a solution for you)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question