Skip to content

Commit 5604205

Browse files
feat: support file: protocol
1 parent 5303db2 commit 5604205

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/utils.js

+9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
MIT License http://www.opensource.org/licenses/mit-license.php
33
Author Tobias Koppers @sokra
44
*/
5+
import { fileURLToPath } from 'url';
56
import path from 'path';
67

78
import { urlToRequest, interpolateName, isUrlRequest } from 'loader-utils';
@@ -82,6 +83,10 @@ function normalizeUrl(url, isStringValue) {
8283
}
8384

8485
function requestify(url, rootContext) {
86+
if (/^file:/i.test(url)) {
87+
return fileURLToPath(url);
88+
}
89+
8590
return mayBeServerRelativeUrl(url)
8691
? urlToRequest(url, rootContext)
8792
: urlToRequest(url);
@@ -521,6 +526,10 @@ function isUrlRequestable(url) {
521526
return true;
522527
}
523528

529+
if (/^file:/i.test(url)) {
530+
return true;
531+
}
532+
524533
return isUrlRequest(url);
525534
}
526535

0 commit comments

Comments
 (0)