bholloway / resolve-url-loader

Webpack loader that resolves relative paths in url() statements based on the original source file
563 stars 71 forks source link

Support for less-loader #41

Closed saskodh closed 7 years ago

saskodh commented 7 years ago

Hi, thanks for writing this loader, it helps me a lot in the migration of older project with Grunt build to Webpack. I tried to use it after a less-loader and it was failing with error 'Source map not available'. After some debugging I noticed that the source map from the less-loader comes as string while in the code it's expected as object. So simple JSON.parse did the job. :)

Cheers!

SebastianS90 commented 7 years ago

@saskodh what is the benefit of using resolve-url-loader after less-loader? less-loader passes the --relative-urls option to less. From the docs:

By default URLs are kept as-is, so if you import a file in a sub-directory that references an image, exactly the same URL will be output in the css. This option allows you to re-write URL's in imported files so that the URL is always relative to the base imported file.

Isn't this exactly what is the purpose of resolve-url-loader and therefore redundant because less already did it?

saskodh commented 7 years ago

@SebastianS90 yes, you are right. Thanks for pointing this out! I didn't know that the less pre-processor is doing that and somehow I didn't noticed it at first. However this loader still helped in few cases (source urls from this version of bootstrap written as string weren't rewritten by the less-loader).

bholloway commented 7 years ago

Sorry @saskodh but this has been trumped by a breaking change in the sass-loader. I am sorry that you will not get contributor credit.

Could you please let me know if #45 will fix your issue.

Use npm i resolve-url-loader@bholloway/resolve-url-loader#feature/support-sass-loader-6