@maizzle/framework 6.0.0-4 → 6.0.0-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
package/src/posthtml/index.js
CHANGED
|
@@ -11,9 +11,10 @@ import envAttributes from './plugins/envAttributes.js'
|
|
|
11
11
|
import { getPosthtmlOptions } from './defaultConfig.js'
|
|
12
12
|
import combineMediaQueries from './plugins/combineMediaQueries.js'
|
|
13
13
|
import defaultComponentsConfig from './defaultComponentsConfig.js'
|
|
14
|
+
import removeRawStyleAttributes from './plugins/removeRawStyleAttributes.js'
|
|
14
15
|
|
|
15
16
|
// PostCSS
|
|
16
|
-
import compileCss from './plugins/postcss/compileCss.js'
|
|
17
|
+
import { compileCss } from './plugins/postcss/compileCss.js'
|
|
17
18
|
|
|
18
19
|
export async function process(html = '', config = {}) {
|
|
19
20
|
/**
|
|
@@ -71,6 +72,7 @@ export async function process(html = '', config = {}) {
|
|
|
71
72
|
|
|
72
73
|
return posthtml([
|
|
73
74
|
...beforePlugins,
|
|
75
|
+
compileCss(config),
|
|
74
76
|
fetchPlugin,
|
|
75
77
|
components(componentsConfig),
|
|
76
78
|
fetchPlugin,
|
|
@@ -80,6 +82,7 @@ export async function process(html = '', config = {}) {
|
|
|
80
82
|
compileCss(config),
|
|
81
83
|
get(config, 'css.combineMediaQueries') !== false
|
|
82
84
|
&& combineMediaQueries(get(config, 'css.combineMediaQueries', { sort: 'mobile-first' })),
|
|
85
|
+
removeRawStyleAttributes(),
|
|
83
86
|
...get(
|
|
84
87
|
config,
|
|
85
88
|
'posthtml.plugins.after',
|
|
@@ -9,7 +9,7 @@ import postcssSafeParser from 'postcss-safe-parser'
|
|
|
9
9
|
import removeDuplicateSelectors from './removeDuplicateSelectors.js'
|
|
10
10
|
import cleanupTailwindArtifacts from './cleanupTailwindArtifacts.js'
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const attributes = new Set([
|
|
13
13
|
'raw',
|
|
14
14
|
'plain',
|
|
15
15
|
'as-is',
|
|
@@ -17,6 +17,9 @@ const validAttributeNames = new Set([
|
|
|
17
17
|
'unprocessed',
|
|
18
18
|
])
|
|
19
19
|
|
|
20
|
+
// export attributes
|
|
21
|
+
export const validAttributeNames = attributes
|
|
22
|
+
|
|
20
23
|
/**
|
|
21
24
|
* PostHTML plugin to process Tailwind CSS within style tags.
|
|
22
25
|
*
|
|
@@ -24,21 +27,14 @@ const validAttributeNames = new Set([
|
|
|
24
27
|
* compiles it with PostCSS. `<style>` tags marked as
|
|
25
28
|
* `no-process` will be skipped.
|
|
26
29
|
*/
|
|
27
|
-
export
|
|
30
|
+
export function compileCss(config = {}) {
|
|
28
31
|
return tree => {
|
|
29
32
|
return new Promise((resolve, reject) => {
|
|
30
33
|
const stylePromises = []
|
|
31
34
|
|
|
32
35
|
tree.walk(node => {
|
|
33
36
|
if (node.tag === 'style' && node.content) {
|
|
34
|
-
if (node.attrs && Object.keys(node.attrs).some(attr =>
|
|
35
|
-
// Remove the attribute
|
|
36
|
-
for (const attr of Object.keys(node.attrs)) {
|
|
37
|
-
if (validAttributeNames.has(attr)) {
|
|
38
|
-
delete node.attrs[attr]
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
37
|
+
if (node.attrs && Object.keys(node.attrs).some(attr => attributes.has(attr))) {
|
|
42
38
|
return node
|
|
43
39
|
}
|
|
44
40
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { validAttributeNames } from "./postcss/compileCss"
|
|
2
|
+
|
|
3
|
+
const plugin = () => tree => {
|
|
4
|
+
const process = node => {
|
|
5
|
+
if (node.tag === 'style') {
|
|
6
|
+
if (node.attrs && Object.keys(node.attrs).some(attr => validAttributeNames.has(attr))) {
|
|
7
|
+
// Remove the attribute
|
|
8
|
+
for (const attr of Object.keys(node.attrs)) {
|
|
9
|
+
if (validAttributeNames.has(attr)) {
|
|
10
|
+
delete node.attrs[attr]
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return node
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return tree.walk(process)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default plugin
|