Skip to content
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

fix: ignore template sources #314

Merged
merged 1 commit into from Aug 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 %>" />