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
Custom importer in modern
api mode may cause ERR_INVALID_URL_SCHEME
error.
#1122
Comments
Yeah, modern API is still experiments, do you want to send a PR with fix? |
I apologize for the delayed response. It seems that you have already fixed it. Thank you very much. I also learnt a lot from your PR. Thank you again. |
@alexander-akait I truly apologize for that. I just found out that the fix for this issue, while solving the problem, has caused a new problem - no files are added to the dependencies so the nested imported SCSS files will not be watched. because the array is empty after being filtered. Line 101 in 4dd92db
I'm very sorry that my carelessness has caused such a big problem. I have created a PR here: #1125 Thank you! |
Bug report
When passing the following
sassOptions
(as shown in the SASS documentation) to sass-loader:In
sass
file usage looks like this:Actual Behavior
when running
webpack build
, the following error is thrown:Expected Behavior
The above error should not occur, as is the case in legacy mode (as seen in the reproduced repository).
How Do We Reproduce?
Reproduce repo:
https://stackblitz.com/edit/sass-loader-err-invalid-url-scheme?file=package.json
Reason and fix
reason
In legacy mode, the
sass.render
method would return included file paths asArray<string>
. In modern mode, thecompile
method returnsArray<URL>
..
Thus, the file
@import 'bgcolor:cornflowerblue'
, imported via a custom importer, will be treated asURL("bgcolor:cornflowerblue")
, with theprotocol
asbgcolor:
. Then, line 101 usesurl.fileURLToPath
to normalize the file path, butfileURLToPath
throws anERR_INVALID_URL_SCHEME
error if theprotocol
is notfile:
(seefileURLToPath
source).sass-loader/src/index.js
Lines 98 to 108 in de29518
In legacy mode, line 115 will not throw an error and line 118 will get
false
, so the error is not encountered.sass-loader/src/index.js
Lines 110 to 122 in de29518
fix
Adding
result.loadedUrls.filter(url=>url.protocol === 'file')....
to line 100 can be a possible fix to ignore invalid URLs.Please paste the results of
npx webpack-cli info
here, and mention other relevant informationOkay, but may be not useful for this issue.
The text was updated successfully, but these errors were encountered: