|
@@ -1013,7 +1013,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
static async processStylesheet(doc, stylesheetContent, cssRules, baseURI, options, batchRequest) {
|
|
static async processStylesheet(doc, stylesheetContent, cssRules, baseURI, options, batchRequest) {
|
|
|
let sheetContent = "", variablesInfo = { index: 0, cssText: "" };
|
|
let sheetContent = "", variablesInfo = { index: 0, cssText: "" };
|
|
|
const urlFunctions = DomUtil.getUrlFunctions(stylesheetContent);
|
|
const urlFunctions = DomUtil.getUrlFunctions(stylesheetContent);
|
|
|
- const urlFunctionData = new Map();
|
|
|
|
|
|
|
+ const resourceInfos = new Map();
|
|
|
await Promise.all(urlFunctions.map(async urlFunction => {
|
|
await Promise.all(urlFunctions.map(async urlFunction => {
|
|
|
const originalResourceURL = DomUtil.matchURL(urlFunction);
|
|
const originalResourceURL = DomUtil.matchURL(urlFunction);
|
|
|
const resourceURL = DomUtil.normalizeURL(originalResourceURL);
|
|
const resourceURL = DomUtil.normalizeURL(originalResourceURL);
|
|
@@ -1021,10 +1021,10 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
const { content, indexResource, duplicate } = await batchRequest.addURL(resourceURL);
|
|
const { content, indexResource, duplicate } = await batchRequest.addURL(resourceURL);
|
|
|
const regExpUrlFunction = DomUtil.getRegExp(urlFunction);
|
|
const regExpUrlFunction = DomUtil.getRegExp(urlFunction);
|
|
|
if (duplicate && options.groupDuplicateImages) {
|
|
if (duplicate && options.groupDuplicateImages) {
|
|
|
- urlFunctionData.set(urlFunction, { regExpUrlFunction, dataURI: content, variableName: "var(" + SINGLE_FILE_VARIABLE_NAME_PREFIX + indexResource + ")" });
|
|
|
|
|
|
|
+ resourceInfos.set(resourceURL, { regExpUrlFunction, dataURI: content, variableName: "var(" + SINGLE_FILE_VARIABLE_NAME_PREFIX + indexResource + ")" });
|
|
|
DomUtil.insertVariable(doc, indexResource, content, options);
|
|
DomUtil.insertVariable(doc, indexResource, content, options);
|
|
|
} else {
|
|
} else {
|
|
|
- urlFunctionData.set(urlFunction, { regExpUrlFunction, dataURI: content });
|
|
|
|
|
|
|
+ resourceInfos.set(resourceURL, { regExpUrlFunction, dataURI: content });
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}));
|
|
}));
|
|
@@ -1055,7 +1055,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
const originalResourceURL = DomUtil.matchURL(urlFunction);
|
|
const originalResourceURL = DomUtil.matchURL(urlFunction);
|
|
|
const resourceURL = DomUtil.normalizeURL(originalResourceURL);
|
|
const resourceURL = DomUtil.normalizeURL(originalResourceURL);
|
|
|
if (resourceURL && resourceURL != baseURI && DomUtil.testValidPath(resourceURL) && cssText.includes(urlFunction)) {
|
|
if (resourceURL && resourceURL != baseURI && DomUtil.testValidPath(resourceURL) && cssText.includes(urlFunction)) {
|
|
|
- const resourceInfo = urlFunctionData.get(urlFunction);
|
|
|
|
|
|
|
+ const resourceInfo = resourceInfos.get(resourceURL);
|
|
|
if (options.groupDuplicateImages && resourceInfo.variableName) {
|
|
if (options.groupDuplicateImages && resourceInfo.variableName) {
|
|
|
cssText = cssText.replace(resourceInfo.regExpUrlFunction, resourceInfo.variableName);
|
|
cssText = cssText.replace(resourceInfo.regExpUrlFunction, resourceInfo.variableName);
|
|
|
} else {
|
|
} else {
|