Skip to content

Commit 078d9bd

Browse files
authoredAug 19, 2020
fix: ignore template sources (#314)
1 parent 8d7db7f commit 078d9bd

7 files changed

+76
-25
lines changed
 

‎src/plugins/source-plugin.js

+9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
parseSrcset,
99
normalizeUrl,
1010
requestify,
11+
isUrlRequestable,
1112
} from '../utils';
1213

1314
export default (options) =>
@@ -85,6 +86,10 @@ export default (options) =>
8586
return;
8687
}
8788

89+
if (!isUrlRequestable(source.value, root)) {
90+
return;
91+
}
92+
8893
const startIndex = valueStartIndex + source.startIndex;
8994
const endIndex = startIndex + source.value.length;
9095

@@ -121,6 +126,10 @@ export default (options) =>
121126
const startIndex = valueStartIndex + source.startIndex;
122127
const endIndex = startIndex + source.value.length;
123128

129+
if (!isUrlRequestable(source.value, root)) {
130+
return;
131+
}
132+
124133
sources.push({
125134
name: attribute,
126135
value: source.value,

‎src/utils.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { stringifyRequest, urlToRequest } from 'loader-utils';
1+
import { stringifyRequest, isUrlRequest, urlToRequest } from 'loader-utils';
22

33
function isASCIIWhitespace(character) {
44
return (
@@ -378,6 +378,10 @@ export function requestify(url, root) {
378378
return urlToRequest(url, root);
379379
}
380380

381+
export function isUrlRequestable(url, root) {
382+
return isUrlRequest(url, root);
383+
}
384+
381385
function isProductionMode(loaderContext) {
382386
return loaderContext.mode === 'production' || !loaderContext.mode;
383387
}

‎test/__snapshots__/attributes-option.test.js.snap

+33-11
Large diffs are not rendered by default.

‎test/__snapshots__/esModule-option.test.js.snap

+9-3
Large diffs are not rendered by default.

‎test/__snapshots__/loader.test.js.snap

+3-1
Large diffs are not rendered by default.

‎test/__snapshots__/minimize-option.test.js.snap

+15-9
Large diffs are not rendered by default.

‎test/fixtures/simple.html

+2
Original file line numberDiff line numberDiff line change
@@ -341,3 +341,5 @@ <h2>An Ordered HTML List</h2>
341341
ANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4
342342
//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU
343343
5ErkJggg==" alt="Red dot" />
344+
345+
<img data-dz-thumbnail="" width="95" height="95" title="<%= name %>" alt="<%= name %>" src="<%= imgsrc %>" />

0 commit comments

Comments
 (0)
Please sign in to comment.