Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,27 @@ module.exports = function(source) {
if (str.indexOf && str.indexOf('"') === 0) {
var replacements = findNestedRequires(str, inlineRequires);
str = fastreplace(str, replacements, function (match) {

if (match.indexOf(',') > -1) {
// Handle srcset
const srcset = match.split(',');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parsing error: The keyword 'const' is reserved

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ESLint defaults to ES5 syntax-checking. You'll want to override to the latest well-supported version of JavaScript. If that's not possible, I will switch back to ES5 syntax.


let srcsetParts = [];

srcset.forEach(src => {
const fileSrcParts = src.trim().split(' ');
const fileSrc = fileSrcParts[0];
const fileStuffix = fileSrcParts[1]
? ` ${fileSrcParts[1]}`
: '';
srcsetParts.push(`" + require('${loaderUtils.stringifyRequest(loaderApi, fileSrc)}') + "${fileStuffix}`);
});

const returnString = srcsetParts.join(',');

return returnString;
}

return "\" + require(" + loaderUtils.stringifyRequest(loaderApi, match) + ") + \"";
});
}
Expand Down