@maizzle/framework 4.4.3 → 4.4.5
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
|
@@ -92,7 +92,9 @@ module.exports = {
|
|
|
92
92
|
|
|
93
93
|
if (buildTemplates) {
|
|
94
94
|
const templateObjects = Array.isArray(buildTemplates) ? buildTemplates : [buildTemplates]
|
|
95
|
-
const
|
|
95
|
+
const configFileTypes = get(buildTemplates, 'filetypes', ['html'])
|
|
96
|
+
const fileTypes = Array.isArray(configFileTypes) ? configFileTypes : configFileTypes.split('|')
|
|
97
|
+
const fileTypesPattern = fileTypes.length > 1 ? `{${fileTypes.join(',')}}` : fileTypes[0]
|
|
96
98
|
|
|
97
99
|
templateObjects.forEach(template => {
|
|
98
100
|
const source = get(template, 'source')
|
|
@@ -101,7 +103,7 @@ module.exports = {
|
|
|
101
103
|
const sources = source(config)
|
|
102
104
|
|
|
103
105
|
if (Array.isArray(sources)) {
|
|
104
|
-
sources.map(s => tailwindConfig.content.files.push(`${s}/**/*.${
|
|
106
|
+
sources.map(s => tailwindConfig.content.files.push(`${s}/**/*.${fileTypesPattern}`))
|
|
105
107
|
} else if (typeof sources === 'string') {
|
|
106
108
|
tailwindConfig.content.files.push(sources)
|
|
107
109
|
}
|
|
@@ -114,7 +116,7 @@ module.exports = {
|
|
|
114
116
|
|
|
115
117
|
// Default behavior - directory sources as a string
|
|
116
118
|
else {
|
|
117
|
-
tailwindConfig.content.files.push(`${source}/**/*.${
|
|
119
|
+
tailwindConfig.content.files.push(`${source}/**/*.${fileTypesPattern}`)
|
|
118
120
|
}
|
|
119
121
|
})
|
|
120
122
|
}
|
|
@@ -6,16 +6,19 @@ const matchHelper = require('posthtml-match-helper')
|
|
|
6
6
|
const defaultConfig = require('../generators/posthtml/defaultConfig')
|
|
7
7
|
|
|
8
8
|
module.exports = async (html, config = {}) => {
|
|
9
|
-
if (get(config, '
|
|
9
|
+
if (get(config, 'removeInlinedSelectors') === false) {
|
|
10
10
|
return html
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
const
|
|
13
|
+
const options = {
|
|
14
|
+
posthtml: merge(defaultConfig, get(config, 'build.posthtml.options', {})),
|
|
15
|
+
removeUnusedCSS: config
|
|
16
|
+
}
|
|
14
17
|
|
|
15
|
-
return posthtml([plugin(
|
|
18
|
+
return posthtml([plugin(options)]).process(html, options.posthtml).then(result => result.html)
|
|
16
19
|
}
|
|
17
20
|
|
|
18
|
-
const plugin =
|
|
21
|
+
const plugin = (options = {}) => tree => {
|
|
19
22
|
const process = node => {
|
|
20
23
|
// For each style tag...
|
|
21
24
|
if (node.tag === 'style') {
|
|
@@ -41,8 +44,16 @@ const plugin = posthtmlOptions => tree => {
|
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
try {
|
|
47
|
+
const safelist = get(options.removeUnusedCSS, 'whitelist', [])
|
|
48
|
+
|
|
44
49
|
// If we find the selector in the HTML...
|
|
45
50
|
tree.match(matchHelper(selector), n => {
|
|
51
|
+
// If the selector is safelisted, preserve it
|
|
52
|
+
if (safelist.some(item => item.endsWith(selector) || item.startsWith(selector))) {
|
|
53
|
+
preservedClasses.push(selector)
|
|
54
|
+
return n
|
|
55
|
+
}
|
|
56
|
+
|
|
46
57
|
const parsedAttrs = parseAttrs(n.attrs)
|
|
47
58
|
const classAttr = get(parsedAttrs, 'class', [])
|
|
48
59
|
const styleAttr = get(parsedAttrs, 'style', {})
|
|
@@ -64,7 +75,7 @@ const plugin = posthtmlOptions => tree => {
|
|
|
64
75
|
|
|
65
76
|
// Fix issue with .compose() automatically quoting attributes with no values
|
|
66
77
|
Object.entries(n.attrs).forEach(([name, value]) => {
|
|
67
|
-
if (value === '' && get(
|
|
78
|
+
if (value === '' && get(options.posthtml, 'recognizeNoValueAttribute') === true) {
|
|
68
79
|
n.attrs[name] = true
|
|
69
80
|
}
|
|
70
81
|
})
|
|
@@ -33,10 +33,10 @@ module.exports = async (html, config = {}, direct = false) => {
|
|
|
33
33
|
{heads: '{{', tails: '}}'},
|
|
34
34
|
{heads: '{%', tails: '%}'}
|
|
35
35
|
],
|
|
36
|
-
whitelist:
|
|
36
|
+
whitelist: get(config, 'whitelist', safelist)
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
const options = merge(defaultOptions,
|
|
39
|
+
const options = merge(defaultOptions, config)
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* Remove possibly inlined selectors, as long as we're not calling
|