-
-
Notifications
You must be signed in to change notification settings - Fork 429
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
Provide loader context #190
Provide loader context #190
Conversation
This is branched off of the change in #189. |
Oh, looks like @jhnns has been maintaining sass-loader. Got a minute for these two one-liner (the same line, no less 😁) PRs? |
Thank you for your pull-request. Could you add a small paragraph to the README describing the feature (e.g. with a use-case)? |
4d54c0d
to
569bb4d
Compare
This allows importers to resolve import paths using Webpack's API and add dependencies to the build.
569bb4d
to
a2045ce
Compare
Here we go! It's... definitely an involved process. You asked for it... 😁 I'm not 100% sure the resolving logic is perfect but it's worked with all the cases I've thrown at it so far. |
NB: There's an "as of 3.1.3" comment in the text, based on the assumption this would be included in the next release. |
Rewrote it the documentation but I noticed a thing or two in sass-loader's path resolution logic that is different than mine (I need to path.normalize and use charAt(0), right?). And I realized it would be ideal to decouple the resolution from the actual processing. Hmmm. But you'd need to specify whether you want Sass-like (foo => _foo, foo.scss, etc.) logic for your importer, I guess. |
We could publish sass-loader's internal functions to the context so that you can use the same functions. |
I like the way you think. Gonna let that ruminate in my brain a bit... |
Mhmm I'm not sure about this feature anymore. It provides access to an API where things might break easily. I don't want to make a major version bump when I'm refactoring internal functions. |
I'm also not sure anymore about the thing I was using this feature for. It was a way to try to get some of the benefits of styles-in-JS via Sass, and it's a pain in a lot of ways. |
Apologies for beating what's probably a very dead horse here, but I think this would be great. I've got a copy of @adamdicarlo's branch and an importer that uses the import colors from 'theo?./colors.json' in javascript, and in sass @import 'theo?format=scss!./colors.json' Even if this never goes anywhere, thanks for the inspiration @adamdicarlo! And for maintaining a great tool, @jhnns |
Thx for pointing out theo. It looks very interesting (although I'm a little disappointed that it's a gulp plugin – it could also be just a small module without gulp dependency). I totally see the benefit. Maybe we could provide the loaderContext to the custom importer, so that you can write your own logic... |
@jhnns funny you should mention - theo-loader coming soon! just trying to get it through legal. meeting with them today |
In case it's useful! https://www.npmjs.com/package/theo-loader |
@jtangelder This allows an importer to really do cool stuff like evaluate other files (use webpack's resolve mechanism) and add them to the build.