Skip to content
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

Will this work with components from other npm modules #7

Closed
eskimoblood opened this issue Oct 8, 2016 · 6 comments
Closed

Will this work with components from other npm modules #7

eskimoblood opened this issue Oct 8, 2016 · 6 comments
Labels

Comments

@eskimoblood
Copy link

In our code base we split out all common stuff in its own npm module, so that every team then can install them into there project. Will your approach also work in this case, when react components comes from node modules?

@andywer
Copy link
Owner

andywer commented Oct 8, 2016

Hi @eskimoblood. That's a good question!

We are currently using postcss-theme in a large (20+ developers, multiple packages) enterprise React app.
Our approach: If you want to be able to theme components in node_modules/, you have got to configure the webpack CSS loader to be run on node_modules/my-other-package/**, too (instead of excluding everything in node_modules).

You can do it like that: webpack/webpack#2031 (comment)

@eskimoblood
Copy link
Author

Thanks, I will give it a try.

@eskimoblood
Copy link
Author

Just another question about node modules. If I understand it correctly it should also be possible to have the themes in its own module and use them with the following postcss setting:

theme({ themePath: '../node_modules/myThemes/theme1' })

@andywer
Copy link
Owner

andywer commented Oct 8, 2016

@eskimoblood Interesting idea. We actually never tried that... But it should work. You might have to make sure the webpack CSS loader is applied to node_modules/myThemes as well.

Please tell us if it works for you or why not :)

@eskimoblood
Copy link
Author

First I need to convince the team to use css modules.

@andywer
Copy link
Owner

andywer commented Oct 9, 2016

Fair enough. FYI: If you need some more lecture or arguments for using it 😉:

We tried traditional SASS, then inline styles with Radium and eventually sticked to CSS modules. Our reasons were:

  • Inline-styling can be pretty tough to debug, since in the browser's dev tools you only see the set of inline-styling rules instead of a cascade of different CSS classes containing subsets of the elements style, thus making tracing back why some rules are applied right in a certain situation rather complicated
  • Inline-styling seems to contradict the W3Cs idea of separating styling rules from the code/markdown
  • There was no media queries and no pseudo-selectors with inline-styling (might have changed meanwhile)
  • Writing CSS rules in a JS object seems just wrong, since you are writing one language in another and have to escape everything (marginLeft: '1.5em' vs margin-left: 1.5em)

@andywer andywer closed this as completed Dec 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants