|
|
@@ -1398,7 +1398,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
|
|
|
const EMPTY_DATA_URI = "data:null;base64,";
|
|
|
const REGEXP_URL_HASH = /(#.+?)$/;
|
|
|
const SINGLE_FILE_VARIABLE_NAME_PREFIX = "--sf-img-";
|
|
|
- const VAR_MAX_SIZE = 512 * 1024;
|
|
|
+ const SINGLE_FILE_VARIABLE_MAX_SIZE = 512 * 1024;
|
|
|
|
|
|
class ProcessorHelper {
|
|
|
static async evalTemplate(template = "", options, content, dontReplaceSlash) {
|
|
|
@@ -1673,7 +1673,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
|
|
|
const tokens = [];
|
|
|
findURLToken(originalResourceURL, declaration.value.children, (token, parent, rootFunction) => {
|
|
|
if (!originalResourceURL.startsWith("#")) {
|
|
|
- if (duplicate && options.groupDuplicateImages && rootFunction && util.getContentSize(content) < VAR_MAX_SIZE) {
|
|
|
+ if (duplicate && options.groupDuplicateImages && rootFunction && util.getContentSize(content) < SINGLE_FILE_VARIABLE_MAX_SIZE) {
|
|
|
const value = cssTree.parse("var(" + SINGLE_FILE_VARIABLE_NAME_PREFIX + indexResource + ")", { context: "value" }).children.head;
|
|
|
tokens.push({ parent, token, value });
|
|
|
variableDefined = true;
|
|
|
@@ -1747,7 +1747,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
|
|
|
const forbiddenPrefixFound = PREFIXES_FORBIDDEN_DATA_URI.filter(prefixDataURI => content.startsWith(prefixDataURI)).length;
|
|
|
if (!forbiddenPrefixFound) {
|
|
|
const isSVG = content.startsWith(PREFIX_DATA_URI_IMAGE_SVG);
|
|
|
- if (processDuplicates && duplicate && options.groupDuplicateImages && !isSVG && util.getContentSize(content) < VAR_MAX_SIZE) {
|
|
|
+ if (processDuplicates && duplicate && options.groupDuplicateImages && !isSVG && util.getContentSize(content) < SINGLE_FILE_VARIABLE_MAX_SIZE) {
|
|
|
if (ProcessorHelper.replaceImageSource(resourceElement, SINGLE_FILE_VARIABLE_NAME_PREFIX + indexResource, options)) {
|
|
|
cssVariables.set(indexResource, content);
|
|
|
const declarationList = cssTree.parse(resourceElement.getAttribute("style"), { context: "declarationList" });
|