@maizzle/framework 4.4.0 → 4.4.1
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": "4.4.
|
|
3
|
+
"version": "4.4.1",
|
|
4
4
|
"description": "Maizzle is a framework that helps you quickly build HTML emails with Tailwind CSS.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"release": "np"
|
|
37
37
|
},
|
|
38
38
|
"files": [
|
|
39
|
-
"src
|
|
39
|
+
"src/**/*",
|
|
40
40
|
"bin/*"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
@@ -5,6 +5,7 @@ const fetch = require('posthtml-fetch')
|
|
|
5
5
|
const layouts = require('posthtml-extend')
|
|
6
6
|
const components = require('posthtml-component')
|
|
7
7
|
const defaultConfig = require('./defaultConfig')
|
|
8
|
+
const defaultComponentsConfig = require('./defaultComponentsConfig')
|
|
8
9
|
|
|
9
10
|
module.exports = async (html, config) => {
|
|
10
11
|
const layoutsOptions = get(config, 'build.layouts', {})
|
|
@@ -35,6 +36,20 @@ module.exports = async (html, config) => {
|
|
|
35
36
|
)
|
|
36
37
|
)
|
|
37
38
|
|
|
39
|
+
const defaultComponentsOptions = merge(
|
|
40
|
+
defaultComponentsConfig,
|
|
41
|
+
{
|
|
42
|
+
folders: [
|
|
43
|
+
...defaultComponentsConfig.folders,
|
|
44
|
+
...get(componentsOptions, 'folders', [])
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
root: componentsOptions.root || './',
|
|
49
|
+
expressions: {...expressionsOptions, locals}
|
|
50
|
+
}
|
|
51
|
+
)
|
|
52
|
+
|
|
38
53
|
return posthtml([
|
|
39
54
|
fetchPlugin,
|
|
40
55
|
layouts(
|
|
@@ -48,15 +63,7 @@ module.exports = async (html, config) => {
|
|
|
48
63
|
),
|
|
49
64
|
components(
|
|
50
65
|
merge(
|
|
51
|
-
|
|
52
|
-
root: componentsOptions.root || './',
|
|
53
|
-
folders: ['src/components', 'src/layouts', 'src/templates'],
|
|
54
|
-
tag: 'component',
|
|
55
|
-
attribute: 'src',
|
|
56
|
-
yield: 'content',
|
|
57
|
-
propsAttribute: 'locals',
|
|
58
|
-
expressions: {...expressionsOptions, locals}
|
|
59
|
-
},
|
|
66
|
+
defaultComponentsOptions,
|
|
60
67
|
componentsOptions
|
|
61
68
|
)
|
|
62
69
|
),
|
|
@@ -7,6 +7,7 @@ const postcssNested = require('tailwindcss/nesting')
|
|
|
7
7
|
const {requireUncached} = require('../utils/helpers')
|
|
8
8
|
const mergeLonghand = require('postcss-merge-longhand')
|
|
9
9
|
const {get, isObject, isEmpty, merge} = require('lodash')
|
|
10
|
+
const defaultComponentsConfig = require('./posthtml/defaultComponentsConfig')
|
|
10
11
|
|
|
11
12
|
const addImportantPlugin = () => {
|
|
12
13
|
return {
|
|
@@ -48,22 +49,24 @@ module.exports = {
|
|
|
48
49
|
|
|
49
50
|
// Merge user's Tailwind config on top of a 'base' config
|
|
50
51
|
const layoutsRoot = get(config, 'build.layouts.root')
|
|
51
|
-
const componentsRoot = get(config, 'build.components.root')
|
|
52
|
+
const componentsRoot = get(config, 'build.components.root', defaultComponentsConfig.root)
|
|
52
53
|
|
|
53
54
|
const layoutsPath = typeof layoutsRoot === 'string' && layoutsRoot ?
|
|
54
|
-
`${layoutsRoot}
|
|
55
|
-
'
|
|
55
|
+
`${layoutsRoot}/**/*.*`.replace(/\/\//g, '/') :
|
|
56
|
+
'src/layouts/**/*.*'
|
|
56
57
|
|
|
57
|
-
const componentsPath =
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
const componentsPath = defaultComponentsConfig.folders.map(folder => {
|
|
59
|
+
return path
|
|
60
|
+
.join(componentsRoot, folder, `**/*.${defaultComponentsConfig.fileExtension}`)
|
|
61
|
+
.replace(/\\/g, '/')
|
|
62
|
+
.replace(/\/\//g, '/')
|
|
63
|
+
})
|
|
60
64
|
|
|
61
65
|
const tailwindConfig = merge({
|
|
62
66
|
content: {
|
|
63
67
|
files: [
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
{raw: html, extension: 'html'}
|
|
68
|
+
...componentsPath,
|
|
69
|
+
layoutsPath
|
|
67
70
|
]
|
|
68
71
|
}
|
|
69
72
|
}, userConfig(config))
|
|
@@ -72,48 +75,53 @@ module.exports = {
|
|
|
72
75
|
if (Array.isArray(tailwindConfig.content)) {
|
|
73
76
|
tailwindConfig.content = {
|
|
74
77
|
files: [
|
|
78
|
+
...componentsPath,
|
|
75
79
|
layoutsPath,
|
|
76
|
-
|
|
77
|
-
...tailwindConfig.content,
|
|
78
|
-
{raw: html, extension: 'html'}
|
|
80
|
+
...tailwindConfig.content
|
|
79
81
|
]
|
|
80
82
|
}
|
|
81
83
|
}
|
|
82
84
|
|
|
85
|
+
// Add raw HTML if using API
|
|
86
|
+
if (html) {
|
|
87
|
+
tailwindConfig.content.files.push({raw: html, extension: 'html'})
|
|
88
|
+
}
|
|
89
|
+
|
|
83
90
|
// Include all `build.templates.source` paths when scanning for selectors to preserve
|
|
84
91
|
const buildTemplates = get(config, 'build.templates')
|
|
85
92
|
|
|
86
93
|
if (buildTemplates) {
|
|
87
94
|
const templateObjects = Array.isArray(buildTemplates) ? buildTemplates : [buildTemplates]
|
|
88
|
-
const
|
|
95
|
+
const fileTypes = get(buildTemplates, 'filetypes', 'html')
|
|
96
|
+
|
|
97
|
+
templateObjects.forEach(template => {
|
|
89
98
|
const source = get(template, 'source')
|
|
90
99
|
|
|
91
100
|
if (typeof source === 'function') {
|
|
92
101
|
const sources = source(config)
|
|
93
102
|
|
|
94
103
|
if (Array.isArray(sources)) {
|
|
95
|
-
sources.map(s => tailwindConfig.content.files.push(s))
|
|
104
|
+
sources.map(s => tailwindConfig.content.files.push(`${s}/**/*.${fileTypes}`))
|
|
96
105
|
} else if (typeof sources === 'string') {
|
|
97
106
|
tailwindConfig.content.files.push(sources)
|
|
98
107
|
}
|
|
99
|
-
|
|
100
|
-
// Must return a valid `content` entry
|
|
101
|
-
return {raw: '', extension: 'html'}
|
|
102
108
|
}
|
|
103
109
|
|
|
104
110
|
// Support single-file sources i.e. src/templates/index.html
|
|
105
|
-
if (typeof source === 'string' && Boolean(path.extname(source))) {
|
|
111
|
+
else if (typeof source === 'string' && Boolean(path.extname(source))) {
|
|
106
112
|
tailwindConfig.content.files.push(source)
|
|
107
|
-
|
|
108
|
-
return {raw: '', extension: 'html'}
|
|
109
113
|
}
|
|
110
114
|
|
|
111
|
-
|
|
115
|
+
// Default behavior - directory sources as a string
|
|
116
|
+
else {
|
|
117
|
+
tailwindConfig.content.files.push(`${source}/**/*.${fileTypes}`)
|
|
118
|
+
}
|
|
112
119
|
})
|
|
113
|
-
|
|
114
|
-
tailwindConfig.content.files.push(...templateSources)
|
|
115
120
|
}
|
|
116
121
|
|
|
122
|
+
// Filter out any duplicate content paths
|
|
123
|
+
tailwindConfig.content.files = [...new Set(tailwindConfig.content.files)]
|
|
124
|
+
|
|
117
125
|
const userFilePath = get(config, 'build.tailwind.css', path.join(process.cwd(), 'src/css/tailwind.css'))
|
|
118
126
|
const userFileExists = await fs.pathExists(userFilePath)
|
|
119
127
|
|