-
-
Notifications
You must be signed in to change notification settings - Fork 193
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
Optional ~ for modules #74
Comments
My problem could actually be solved by supporting Less |
I would like to change that as well... it's counter-intuitive and forces you to write your less files in a way that just webpack is able to understand it. However, it was @sokra 's decision back then and I don't know if it's wise to change that now with a major version bump. That would probably force a lot of people to refactor their code 😁 |
It would be nice to see this change though, so our Less modules can be loaded with a non-webpack-stack as well. |
I've thought about this today. We could make it optional by first doing a lookup with However, the problem still remains with It's a tough decision because the Additionally, we should align this decision with the sass-loader, as it is very similar to the less-loader. |
Concerning your PR #75: I'd first like to have a decision here. Because in case we remove |
That's fine. I totally understand your concerns and didn't knew that css-loader is responsible for image loading. You're right: this should be addressed in all loaders. For all loaders I'd like to either use relative ( |
CSS and less only know about relative urls, they have no idea what "modules" are... Both less-loader and css-loader are designed to handle existing code well. So So the The less-loader aligns with the underlying less language. It doesn't change the language it only adds the So the best way to add modules to the less-loader would be to add module urls to the less language. Maybe something like Trying to resolve both, first normal, than as module, would be a webpack-only extension to the less language and would not be better than Related: |
Yes, correct. That's why we should not change the semantics. Basically, writing
I don't think that this would be a webpack-only way. It's basically the same as when using the |
Yes, but I'd expect that the |
With "bower" you mean LESS? 😀 And yes, LESS is actually considering to enable this via option |
Sorry, I meant "Bootstrap" instead of "Bower", because the example sokra mentioned was Bootstrap :D |
I'd like to come to a conclusion here. As seen in #79 and #81 more people are bitten by this recently. I'll try to breakdown the current status quo:
My proposal: Try resolving Less files relative by default. If you can't find a relative file use Webpacks module resolving logic to find a corresponding module (just like it would work if you use |
It will be really nice if we can write code that isn't only for webpack. Currently, the compulsion to use |
Surprised no one has yet mentioned omit-tilde-webpack-plugin. While it does not directly solve the problem, it is very related and may help a few folks out (or maybe show some precedent for optional |
I agree, is there some technical reason why we can't do this? |
@timmfin Wow, thank you. I have to try that with our code base! |
I don't think so. Imho it should be safe to prefer the local one first and then to look for module directories. But for a consistent behavior this needs to be adjusted in the less-loader, sass-loader, css-loader and html-loader (and probably some more, but these are the most important ones imho). That's why I would like to have @sokra 's commitment... |
Guys please keep stuff sane and stick to standards, if less supports a --inclue-path option, less-loader for webpack should do so too. |
It's not an obvious fault. It's a valid discussion. And as I've already pointed out: it needs to be consistent across different loaders (e.g. the css-loader resolves |
@jhnns |
FYI: The omit-tilde-webpack-plugin doesn't seem to work for dependencies of dependencies. bholloway/omit-tilde-webpack-plugin#5 |
My intention in writing However who is to say that @donaldpipowitch's use case is not just a ...really...long...migration... (wink) Super busy right now but will try to take a look at bholloway/omit-tilde-webpack-plugin#5. |
I really just want to re-use our existing Less modules (about ~20 or so?) which should continue to work with the vanilla Less compiler without webpack. I don't want to write a lot more modules in this style. (Ideally we would switch to something completely different than Less in the future anyway :)) Thank you for investigating. But besides migration... I still wouldn't want to publish new projects in Less, Sass or whatever with |
I can totally understand this desire. However, I think it would also be sufficient to have a tilde-less-plugin (similar to the less-plugin-npm-import) which allows you to compile LESS modules without webpack. |
Yeah. Actually that is quite a nice idea. I already developed Mercateo/less-plugin-bower-resolve before. That was 2 years ago... I didn't even thought about something like that... Don't know how it would work with |
FYI: My issue with Thanks everyone for participating in this discussion. I leave it up to you to close this issue or to discuss further, if this should be the default behaviour of webpack. |
Starting with less-loader 4, you can now choose between webpack's resolver and the default Less resolver: https://github.com/webpack-contrib/less-loader#imports |
Why do I need to prepend
~
for modules? I'd rather prepend./
for relative files. This seems to work great, when I comment this line:var moduleRequest = loaderUtils.urlToRequest(filename, query.root);
Can we make
~
optional?The text was updated successfully, but these errors were encountered: