@maizzle/framework 4.4.0-beta.12 → 4.4.0-beta.14
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
|
@@ -8,6 +8,22 @@ const {requireUncached} = require('../utils/helpers')
|
|
|
8
8
|
const mergeLonghand = require('postcss-merge-longhand')
|
|
9
9
|
const {get, isObject, isEmpty, merge} = require('lodash')
|
|
10
10
|
|
|
11
|
+
const addImportantPlugin = () => {
|
|
12
|
+
return {
|
|
13
|
+
postcssPlugin: 'add-important',
|
|
14
|
+
Rule(rule) {
|
|
15
|
+
const shouldAddImportant = get(rule, 'raws.tailwind.layer') === 'variants'
|
|
16
|
+
|| get(rule, 'parent.type') === 'atrule'
|
|
17
|
+
|
|
18
|
+
if (shouldAddImportant) {
|
|
19
|
+
rule.walkDecls(decl => {
|
|
20
|
+
decl.important = true
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
11
27
|
module.exports = {
|
|
12
28
|
compile: async ({css = '', html = '', config = {}}) => {
|
|
13
29
|
// Compute the Tailwind config to use
|
|
@@ -34,25 +50,30 @@ module.exports = {
|
|
|
34
50
|
const layoutsRoot = get(config, 'build.layouts.root')
|
|
35
51
|
const componentsRoot = get(config, 'build.components.root')
|
|
36
52
|
|
|
53
|
+
const layoutsPath = typeof layoutsRoot === 'string' && layoutsRoot ?
|
|
54
|
+
`${layoutsRoot}/**/*.html`.replace(/\/\//g, '/') :
|
|
55
|
+
'./src/layouts/**/*.html'
|
|
56
|
+
|
|
57
|
+
const componentsPath = typeof componentsRoot === 'string' && componentsRoot ?
|
|
58
|
+
`${componentsRoot}/**/*.html`.replace(/\/\//g, '/') :
|
|
59
|
+
'./src/components/**/*.html'
|
|
60
|
+
|
|
37
61
|
const tailwindConfig = merge({
|
|
38
|
-
important: true,
|
|
39
62
|
content: {
|
|
40
63
|
files: [
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
'./src/layouts/**/*.html',
|
|
44
|
-
typeof componentsRoot === 'string' && componentsRoot ?
|
|
45
|
-
`${componentsRoot}/**/*.html`.replace(/\/\//g, '/') :
|
|
46
|
-
'./src/components/**/*.html',
|
|
64
|
+
layoutsPath,
|
|
65
|
+
componentsPath,
|
|
47
66
|
{raw: html, extension: 'html'}
|
|
48
67
|
]
|
|
49
68
|
}
|
|
50
69
|
}, userConfig(config))
|
|
51
70
|
|
|
52
|
-
//
|
|
71
|
+
// If `content` is an array, add it to `content.files`
|
|
53
72
|
if (Array.isArray(tailwindConfig.content)) {
|
|
54
73
|
tailwindConfig.content = {
|
|
55
74
|
files: [
|
|
75
|
+
layoutsPath,
|
|
76
|
+
componentsPath,
|
|
56
77
|
...tailwindConfig.content,
|
|
57
78
|
{raw: html, extension: 'html'}
|
|
58
79
|
]
|
|
@@ -99,6 +120,7 @@ module.exports = {
|
|
|
99
120
|
const toProcess = [
|
|
100
121
|
postcssNested(),
|
|
101
122
|
tailwindcss(tailwindConfig),
|
|
123
|
+
get(tailwindConfig, 'important') === false ? () => {} : addImportantPlugin(),
|
|
102
124
|
get(config, 'shorthandCSS', get(config, 'shorthandInlineCSS')) === true ?
|
|
103
125
|
mergeLonghand() :
|
|
104
126
|
() => {},
|
|
@@ -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
|
}
|