@maizzle/framework 4.4.0-beta.12 → 4.4.0-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -53,7 +53,7 @@ exports.addURLParams = (html, config) => addURLParams(html, config, true)
|
|
|
53
53
|
exports.preventWidows = (html, config) => preventWidows(html, config)
|
|
54
54
|
exports.replaceStrings = (html, config) => replaceStrings(html, config, true)
|
|
55
55
|
exports.safeClassNames = (html, config) => safeClassNames(html, config, true)
|
|
56
|
-
exports.removeUnusedCSS = (html, config) => removeUnusedCSS(html, config)
|
|
56
|
+
exports.removeUnusedCSS = (html, config) => removeUnusedCSS(html, config, true)
|
|
57
57
|
exports.removeAttributes = (html, config) => removeAttributes(html, config, true)
|
|
58
58
|
exports.attributeToStyle = (html, config) => attributeToStyle(html, config, true)
|
|
59
59
|
exports.removeInlineSizes = (html, config) => removeInlineSizes(html, config, true)
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
const {comb} = require('email-comb')
|
|
2
|
-
const {get, merge} = require('lodash')
|
|
2
|
+
const {get, merge, isEmpty, isObject} = require('lodash')
|
|
3
3
|
const removeInlinedClasses = require('./removeInlinedSelectors')
|
|
4
4
|
|
|
5
|
-
module.exports = async (html, config = {}) => {
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
module.exports = async (html, config = {}, direct = false) => {
|
|
6
|
+
config = direct ? config : get(config, 'removeUnusedCSS')
|
|
7
|
+
|
|
8
|
+
// Don't purge CSS if `removeUnusedCSS` is not set
|
|
9
|
+
if (!config || (isObject(config) && isEmpty(config))) {
|
|
8
10
|
return html
|
|
9
11
|
}
|
|
10
12
|
|
|
@@ -34,9 +36,13 @@ module.exports = async (html, config = {}) => {
|
|
|
34
36
|
whitelist: [...get(config, 'whitelist', []), ...safelist]
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
const options = merge(defaultOptions, get(config, 'removeUnusedCSS',
|
|
39
|
+
const options = merge(defaultOptions, get(config, 'removeUnusedCSS', {}))
|
|
38
40
|
|
|
39
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Remove possibly inlined selectors, as long as we're not calling
|
|
43
|
+
* this function directly, i.e. Maizzle.removeUnusedCSS()
|
|
44
|
+
* */
|
|
45
|
+
html = direct ? html : await removeInlinedClasses(html, options)
|
|
40
46
|
|
|
41
47
|
return comb(html, options).result
|
|
42
48
|
}
|