@maizzle/framework 5.0.0-beta.5 → 5.0.0-beta.7
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maizzle/framework",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.7",
|
|
4
4
|
"description": "Maizzle is a framework that helps you quickly build HTML emails with Tailwind CSS.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"ws": "^8.17.0"
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
95
|
-
"@biomejs/biome": "
|
|
95
|
+
"@biomejs/biome": "1.8.3",
|
|
96
96
|
"@types/js-beautify": "^1.14.3",
|
|
97
97
|
"@types/markdown-it": "^14.1.1",
|
|
98
98
|
"@vitest/coverage-v8": "^2.0.1",
|
package/src/posthtml/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import posthtmlPostcss from 'posthtml-postcss'
|
|
|
8
8
|
import defaultPosthtmlConfig from './defaultConfig.js'
|
|
9
9
|
import expandLinkTag from './plugins/expandLinkTag.js'
|
|
10
10
|
import envAttributes from './plugins/envAttributes.js'
|
|
11
|
+
import envTags from './plugins/envTags.js'
|
|
11
12
|
|
|
12
13
|
// PostCSS
|
|
13
14
|
import tailwindcss from 'tailwindcss'
|
|
@@ -51,6 +52,7 @@ export async function process(html = '', config = {}) {
|
|
|
51
52
|
|
|
52
53
|
return posthtml([
|
|
53
54
|
...get(config, 'posthtml.plugins.before', []),
|
|
55
|
+
envTags(config.env),
|
|
54
56
|
envAttributes(config.env),
|
|
55
57
|
expandLinkTag,
|
|
56
58
|
postcssPlugin,
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const plugin = (env => tree => {
|
|
2
|
+
const process = node => {
|
|
3
|
+
env = env || 'local'
|
|
4
|
+
|
|
5
|
+
// Return the original node if it doesn't have a tag
|
|
6
|
+
if (!node.tag) {
|
|
7
|
+
return node
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const tagEnv = node.tag.split(':').pop()
|
|
11
|
+
|
|
12
|
+
// Tag targets current env, remove it and return its content
|
|
13
|
+
if (node.tag.endsWith(`:${env}`)) {
|
|
14
|
+
node.tag = false
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Tag doesn't target current env, remove it completely
|
|
18
|
+
if (
|
|
19
|
+
typeof node.tag === 'string'
|
|
20
|
+
&& node.tag.startsWith('env:')
|
|
21
|
+
&& tagEnv !== env
|
|
22
|
+
) {
|
|
23
|
+
node.content = []
|
|
24
|
+
node.tag = false
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return node
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return tree.walk(process)
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
export default plugin
|
package/src/transformers/core.js
CHANGED
|
@@ -11,6 +11,18 @@ const posthtmlPlugin = (config = {}) => tree => {
|
|
|
11
11
|
node.content = ['']
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Custom attributes to prevent inlining CSS from <style> tags
|
|
16
|
+
*/
|
|
17
|
+
if (
|
|
18
|
+
node.tag === 'style'
|
|
19
|
+
&& (node.attrs?.['no-inline'] || node.attrs?.embed)
|
|
20
|
+
) {
|
|
21
|
+
node.attrs['no-inline'] = false
|
|
22
|
+
node.attrs.embed = false
|
|
23
|
+
node.attrs['data-embed'] = true
|
|
24
|
+
}
|
|
25
|
+
|
|
14
26
|
return node
|
|
15
27
|
}
|
|
16
28
|
|