|
|
@@ -736,7 +736,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
await Promise.all(Array.from(this.doc.querySelectorAll("style, link[rel*=stylesheet]"))
|
|
|
.map(async element => {
|
|
|
this.stylesheets.set(element, { media: element.media });
|
|
|
- const options = { maxResourceSize: this.options.maxResourceSize, maxResourceSizeEnabled: this.options.maxResourceSizeEnabled, url: this.options.url, charSet: this.charSet };
|
|
|
+ const options = { maxResourceSize: this.options.maxResourceSize, maxResourceSizeEnabled: this.options.maxResourceSizeEnabled, url: this.options.url, charSet: this.charSet, compressCSS: this.options.compressCSS };
|
|
|
const isLinkTag = element.tagName.toLowerCase() == "link";
|
|
|
if (isLinkTag && element.rel.includes("alternate") && element.title) {
|
|
|
element.remove();
|
|
|
@@ -1099,9 +1099,6 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
|
|
|
static async resolveImportURLs(stylesheetContent, baseURI, options) {
|
|
|
stylesheetContent = DomProcessorHelper.resolveStylesheetURLs(stylesheetContent, baseURI, options);
|
|
|
- if (options.compressCSS) {
|
|
|
- stylesheetContent = DomUtil.removeCssComments(stylesheetContent);
|
|
|
- }
|
|
|
const imports = DomUtil.getImportFunctions(stylesheetContent);
|
|
|
await Promise.all(imports.map(async cssImport => {
|
|
|
const match = DomUtil.matchImport(cssImport);
|
|
|
@@ -1112,6 +1109,9 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
if (DomUtil.testValidURL(resourceURL, baseURI, options.url)) {
|
|
|
const downloadOptions = { asDataURI: false, maxResourceSize: options.maxResourceSize, maxResourceSizeEnabled: options.maxResourceSizeEnabled, validateTextContentType: true };
|
|
|
let importedStylesheetContent = await Download.getContent(resourceURL, downloadOptions);
|
|
|
+ if (options.compressCSS) {
|
|
|
+ importedStylesheetContent = DomUtil.removeCssComments(importedStylesheetContent);
|
|
|
+ }
|
|
|
importedStylesheetContent = DomUtil.wrapMediaQuery(importedStylesheetContent, match.media);
|
|
|
if (stylesheetContent.includes(cssImport)) {
|
|
|
importedStylesheetContent = await DomProcessorHelper.resolveImportURLs(importedStylesheetContent, resourceURL, options);
|
|
|
@@ -1153,6 +1153,9 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
if (resourceURL && resourceURL != baseURI && resourceURL != ABOUT_BLANK_URI) {
|
|
|
const downloadOptions = { asDataURI: false, maxResourceSize: options.maxResourceSize, maxResourceSizeEnabled: options.maxResourceSizeEnabled, charSet: options.charSet };
|
|
|
let stylesheetContent = await Download.getContent(resourceURL, downloadOptions);
|
|
|
+ if (options.compressCSS) {
|
|
|
+ stylesheetContent = DomUtil.removeCssComments(stylesheetContent);
|
|
|
+ }
|
|
|
stylesheetContent = await DomProcessorHelper.resolveImportURLs(stylesheetContent, resourceURL, options);
|
|
|
return stylesheetContent;
|
|
|
}
|