Skip to content

Commit

Permalink
fix: ignore template sources (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi committed Aug 19, 2020
1 parent 8d7db7f commit 078d9bd
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 25 deletions.
9 changes: 9 additions & 0 deletions src/plugins/source-plugin.js
Expand Up @@ -8,6 +8,7 @@ import {
parseSrcset,
normalizeUrl,
requestify,
isUrlRequestable,
} from '../utils';

export default (options) =>
Expand Down Expand Up @@ -85,6 +86,10 @@ export default (options) =>
return;
}

if (!isUrlRequestable(source.value, root)) {
return;
}

const startIndex = valueStartIndex + source.startIndex;
const endIndex = startIndex + source.value.length;

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

if (!isUrlRequestable(source.value, root)) {
return;
}

sources.push({
name: attribute,
value: source.value,
Expand Down
6 changes: 5 additions & 1 deletion src/utils.js
@@ -1,4 +1,4 @@
import { stringifyRequest, urlToRequest } from 'loader-utils';
import { stringifyRequest, isUrlRequest, urlToRequest } from 'loader-utils';

function isASCIIWhitespace(character) {
return (
Expand Down Expand Up @@ -378,6 +378,10 @@ export function requestify(url, root) {
return urlToRequest(url, root);
}

export function isUrlRequestable(url, root) {
return isUrlRequest(url, root);
}

function isProductionMode(loaderContext) {
return loaderContext.mode === 'production' || !loaderContext.mode;
}
Expand Down
44 changes: 33 additions & 11 deletions test/__snapshots__/attributes-option.test.js.snap

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions test/__snapshots__/esModule-option.test.js.snap

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion test/__snapshots__/loader.test.js.snap

Large diffs are not rendered by default.

24 changes: 15 additions & 9 deletions test/__snapshots__/minimize-option.test.js.snap

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions test/fixtures/simple.html
Expand Up @@ -341,3 +341,5 @@ <h2>An Ordered HTML List</h2>
ANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4
//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU
5ErkJggg==" alt="Red dot" />

<img data-dz-thumbnail="" width="95" height="95" title="<%= name %>" alt="<%= name %>" src="<%= imgsrc %>" />

0 comments on commit 078d9bd

Please sign in to comment.