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
example of using inuitcss in a webpack project #113
Comments
Hey, currently there’s no example as we’re still in progress of porting over the individual modules to this new repo and improve it. Our plan though is to provide a way better documentation, including examples such as your requested one. Thanks for the request, we’ll try to provide it soon. :) |
Do you guys have a time estimate for when the documentation could go out? Just curious. |
@thosetinydreams it's not an ETA, but you'd be able to follow the progress here. |
Cool, thanks, @nenadjelovac! |
@thosetinydreams no problems ;) |
If it can help, I have integrated the duckduckgo-styles in a webpack project: This setup is complex because duckduckgo rely on compass and litestrap (itself relying on animate) Note:
|
Hi! I'm also using webpack with inuit.css. I'm using postcss-loader + sass and my main.scss (which get's imported by my root React.js component) which looks like the example main.scss provided. Works fine. If you want an example, see https://github.com/nightgrey/3dstheme-portal and check out this files/folders:
Essentially, the workflow is not different from any other sass library and/or file. I also have a problem/suggestion for those using inuit.css in webpack. I'm not sure if the place is correct or if I should create a new issue. What do the owners think? I'll write it down here for now, I can move/edit if desired. Problem/suggestion Example Solution/proposal/idea
I'd do a pull request for this if this is something desired by the repo owners. I'm also not sure if that's just my problem. Maybe all other guys are using one main.scss and boom, done. How do you guys do it? |
@nightgrey I don't think the problem occurs from the reason you described, but I did face this when trying to make some js components work independently from my project's main code base, and the same would happen if you use injected stylesheets, like with the style parameter in angular components. The solution you suggest is not a great one by itself, since if you have more than one file with the same dependencies it would make duplicated code in the output. That's because sass' imports are triggered every time they appear. A better idea would be to implement an "import-once" kinda thing. It's one of the features confirmed for sass 4, but until then there are some custom solutions out there, and I have an idea on how to make one, based around dependencies declarations, that would suit inuitcss. If there is interest I can make a PR. |
Also, it would be great for documentation, since each piece of code would have it's dependencies declared. |
You mean that compilation fails (in my given case) because webpack's order of importing JS and SASS/CSS is not guaranteed? It actually is the cause of the problem. Check out these quotes from webpack developers: From webpack/webpack#215 (comment)
From https://webpack.github.io/docs/stylesheets.html
That's why you're importing, f.e., React in every file you need it.
Huh. I didn't know this (and didn't notice), but you're right! Thanks. In this case, my solution is pretty bad. I assumed Webpack uses the Also, I'm curious about your idea! Do you mind explaining? Edit: I just found this. There are others like sass-loader-once, but it just imports once, it does not sort anything or checks what file needs which import, so some variables are still be undefined. I'll check fast-sass-loader and report back. It might be a workaround until inuit.css itself has a solution, or there is a preferred official solution by inuit.css or Sass. |
This has nothing to do with What you need is a way to declare and load dependencies, as I said. It's really necessary to be able to take full advantage from module loaders, especially with stuff like Angular 2. I'll make the PR I mentioned anyway, and we can take it from there. |
@herzinger I think I could've put it better, but I'm pretty sure we're talking about the exact same thing, we just misunderstood each other. Sorry for the confusion. To make it clear: I'm not trying to say the import order WITHIN a file is random. The order is as expected if I import file C after file B in file A - no argument here. It would be awkward if this was random, and yes, order is ITCSS whole point. I also know why my example in my first post in this issue fails. That's why I'd like to see this to work like in JavaScript - with declared dependencies. The exact same thng you're talking about. ;-) Please make the PR (or maybe an example)! I mean, I get what declaring dependencies is, I just can't think of an actual example without duplicate imports/code output. |
Can someone from the core team comment on this? As it's considerable work, and after some of my last submits, I don't want to jump into it before making sure it'll be used. Some points:
I'll do it anyway, since it's great for the kind of work I do, but depending on the answer I'll do it in a fork, and without much hurry. |
@nightgrey @herzinger To be honest, I never used webpack in my life. I barely now what it's good for and all you have written about above, I don't really understand 😞. That being said, I'm not exactly sure what's being expected from us here? In the first place, I assumed it's just about a documentation thing of "how to use inuitcss in a webpack project", so we would write some instructions like: "do this and that in your webpack config file, and make sure you don't forget to..." and that's it. After re-reading this thread, it seems like we have to completely rewrite our code, just to be able to be used in a webpack project. If that's the case, it rings some warning bells in my head, because I always believed that any kind of CSS framework should be able to be used in any kind of build tool or whatever environment without doing any kind of specific work for the respective tool it's being used in. Can you please elaborate, what you specifically expect from inuitcss to be able to be used in a webpack project? |
@csshugs That is not the case. The feature I suggested is necessary to use one of the great features of module loaders, that allow you to encapsulate the style for a component together with said component. It means you could distribute it as a single .js file, with no other dependency, having both style and template embedded in it. It's great, specially for bigger projects and for stuff that can be reutilized often. You can still use inuitcss as is by linking a main css file in your project index like normal (with a little extra setup), you just would loose a lot of the modularity of your components (which is the main reason to use a module loader in the first place). It also wouldn't mean completely rewriting inuitcss. What I meant when I said "It would require work across the framework" was that I would make a small addition to each partial, and it would need to live there, so there's no way to just add some external files to the project and get it to work, like a plugin would. |
@herzinger I'm sorry, but I still don't know what we would have to do exactly to suit your needs. Do you have any code examples of what we would have to do? I'm sorry for my newbie knowledge concerning this topic, but I really have to understand this thoroughly to judge about it. |
It's worth to note that I don't believe any mainstream css framework is ready for that quite yet. Popularization of module loaders is a pretty new phenomenon (I believe it to be the next big front-end paradigma, to be honest), and this particular solution is something from the top of my head. I never saw it implemented - although I do know it works. SASS 4 is expected to ship with |
Ah Ok. That confirms my scepticism. |
@csshugs It's a dependencies injection/declarations system, but that's okay if you don't understand for now, I would do it myself. I just want to know if, knowing the points I presented, it's something you would be okay seeing in inuitcss. |
@csshugs bottom line: for this to work, each partial has to be able to function by itself. It has to know if everything it needs is there, and if not, load it in the correct order. When you write a component, you link it to a single file, and it's loaded on demand. |
Giving this fact:
... IMO it's not something to be implemented now (i.e. for version 6.0.0). If it's still an upcoming trend, I think it would be sensible to wait how this concept develops in the CSS community. And don't get me wrong: It sounds like a great concept. I just don't want to navigate inuitcss into a deadlock. |
Copy that! Thanks for explaining. Let's see what @inuitcss/core has to say about it. |
Okay, I'll make a fork them, for now, and link it here after it's up. I follow inuitcss for many years now and kinda see it as a trend setter, so I would be happy to see it ahead of the curve once more. |
Since we don't consider this topic to be relevant for inuitcss currently, I like to close this for now and see how the CSS community develops in the future and think about this again, when it is a more common standard in the community. Until then, we are keen seeing forks of inuitcss addressing and incorporating this. Thank you @herzinger for explaining things thoroughly and everyone else for their opinions in this discussions. |
I have setup a boilerplate with "create-react-app-typescript" which includes a way of working with inuitcss. https://github.com/yourownmood/react-inuitcss-boilerplate Maybe you can borrow the same approach of handling scss and inuitcss in your project |
I am trying to integrate inuitcss in my webpack app.
The webpack project I am using is using a custom loader to load bootstrap-sass which seams quite complicated https://github.com/erikras/react-redux-universal-hot-example/blob/master/webpack/dev.config.js
Is there any example on how to do that with inuitcss?
The text was updated successfully, but these errors were encountered: