-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Less files in components #86
Comments
@ilyadoroshin you can google for component-based UI development, take a look here for example: The purpose of this is to have independent from each other components, instead of sharing styles and other assets between components you use composition. This allows to avoid possible bugs, when editing a shared resource for one component may break another one which depends on the same shared resource (CSS, image etc.) |
@koistya thanks, i know a lot about bem, use it everywhere, i just cannot get what does react do with that less file inside of component? |
@ilyadoroshin as opposed to have shared folders for styles, images? If you have all the resources referenced by the component in a single place (inside component's folder), you will be able to easily find them, you will be confident that editing these files won't affect other components. You can also remove component's folder and be sure that you have not left any assets which are no longer in use. |
@ilyadoroshin or, do you mean, why LESS and not SASS or Stylus or plain CSS? |
@koistya oh, so you're saying, that under the hood, less files are combined together from all components into one file, right? |
Regarding how does it work.. during the application bundling process, those CSS/LESS files are aggregated and embedded into the bundle itself (alternatively an external style.css file can be created, depending on your build config). Check this out: |
@koistya sick 👍 |
For example, you may have a Navigation React component with the following files:
Inside your CSS or React code you can reference that image using relative path:
And when you build the project, this |
@koistya jee, man, that's awesome! |
@koistya Actually, I've got only one question left. I'm used to sass, and I moved everything to sass, but build fails because import of component's sass-file fails. |
@ilyadoroshin try to replace react-starter-kit/webpack.config.js Lines 66 to 70 in 7910f58
|
@koistya tried this one, I get |
|
@koistya nope.. still not loading. |
Are you sure you have |
@koistya I've done all exactly as you said:
|
It seems like Have you installed |
@koistya that works! But for proper sass (not scss) support need to add ?indentedStyle to sass-loader Thanks a bunch! |
@ilyadoroshin how did you solve the import of normalize.css after you switched from less to scss?
|
@cmnstmntmn Try to remove |
Hey, guys.
I must've msised something, but why do we add less-files into components? What's the purpose on that and how does it work (link on docs will do, google couldn't help me).
Thanks in advance!
The text was updated successfully, but these errors were encountered: