From 33b07b2a59d1737006a7e37403e812c075ed8e41 Mon Sep 17 00:00:00 2001 From: Cosmin Popovici Date: Sun, 16 Oct 2022 17:53:08 +0300 Subject: [PATCH] fix: run removeUnusedCSS only if enabled --- src/transformers/index.js | 2 +- src/transformers/removeUnusedCss.js | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/transformers/index.js b/src/transformers/index.js index 5f1be342..cee5d921 100644 --- a/src/transformers/index.js +++ b/src/transformers/index.js @@ -54,7 +54,7 @@ exports.addURLParams = (html, config) => addURLParams(html, config, true) exports.preventWidows = (html, config) => preventWidows(html, config) exports.replaceStrings = (html, config) => replaceStrings(html, config, true) exports.safeClassNames = (html, config) => safeClassNames(html, config, true) -exports.removeUnusedCSS = (html, config) => removeUnusedCSS(html, config) +exports.removeUnusedCSS = (html, config) => removeUnusedCSS(html, config, true) exports.removeAttributes = (html, config) => removeAttributes(html, config, true) exports.attributeToStyle = (html, config) => attributeToStyle(html, config, true) exports.removeInlineSizes = (html, config) => removeInlineSizes(html, config, true) diff --git a/src/transformers/removeUnusedCss.js b/src/transformers/removeUnusedCss.js index 8d58f80b..a7984529 100644 --- a/src/transformers/removeUnusedCss.js +++ b/src/transformers/removeUnusedCss.js @@ -1,11 +1,15 @@ const {comb} = require('email-comb') const {get, merge} = require('lodash') -module.exports = async (html, config = {}) => { +module.exports = async (html, config = {}, direct = false) => { if (get(config, 'removeUnusedCSS') === false) { return html } + if (!direct && !get(config, 'removeUnusedCSS')) { + return html + } + const safelist = [ '*body*', // Gmail '.gmail*', // Gmail @@ -13,7 +17,7 @@ module.exports = async (html, config = {}) => { '.ios*', // Mail on iOS '.ox-*', // Open-Xchange '.outlook*', // Outlook.com - '.ogs*', // Outlook.com + '[data-ogs*', // Outlook.com '.bloop_container', // Airmail '.Singleton', // Apple Mail 10 '.unused', // Notes 8