@maizzle/framework 5.0.0-beta.36 → 5.0.0-beta.38

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.36",
3
+ "version": "5.0.0-beta.38",
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",
@@ -175,7 +175,7 @@ export default async (config = {}) => {
175
175
  const outputExtensions = new Set()
176
176
 
177
177
  for (const pattern of contentPaths) {
178
- outputExtensions.add(...getFileExtensionsFromPattern(pattern))
178
+ getFileExtensionsFromPattern(pattern).map(ext => outputExtensions.add(ext))
179
179
  }
180
180
 
181
181
  /**
@@ -210,7 +210,26 @@ export default async (config = {}) => {
210
210
 
211
211
  const html = await readFile(templatePath, 'utf8')
212
212
 
213
- const rendered = await render(html, config)
213
+ /**
214
+ * Render the markup.
215
+ *
216
+ * Merging a custom `components` object to make sure that file extensions from both
217
+ * `build.content` * and * `components.fileExtension` are used when scanning for
218
+ * component files.
219
+ */
220
+ const userComponentFileExtensions = get(config, 'components.fileExtension', ['html'])
221
+
222
+ const rendered = await render(html, merge(
223
+ {
224
+ components: {
225
+ fileExtension: [
226
+ ...outputExtensions,
227
+ ...(new Set([].concat(userComponentFileExtensions))),
228
+ ],
229
+ }
230
+ },
231
+ config
232
+ ))
214
233
 
215
234
  /**
216
235
  * Generate plaintext
@@ -1,7 +1,7 @@
1
1
  export default {
2
2
  root: './',
3
3
  tag: 'component',
4
- fileExtension: 'html',
4
+ fileExtension: ['html'],
5
5
  folders: [
6
6
  'layouts',
7
7
  'emails',
@@ -82,6 +82,24 @@ export async function process(html = '', config = {}) {
82
82
  )
83
83
  )
84
84
 
85
+ const componentsConfig = merge(
86
+ {
87
+ expressions: merge(
88
+ { locals },
89
+ expressionsOptions,
90
+ )
91
+ },
92
+ componentsUserOptions,
93
+ defaultComponentsConfig
94
+ )
95
+
96
+ // Ensure `fileExtension` is array and has no duplicates
97
+ componentsConfig.fileExtension = [...new Set(
98
+ Array.isArray(componentsConfig.fileExtension)
99
+ ? componentsConfig.fileExtension
100
+ : [componentsConfig.fileExtension]
101
+ )]
102
+
85
103
  return posthtml([
86
104
  ...get(config, 'posthtml.plugins.before', []),
87
105
  envTags(config.env),
@@ -89,18 +107,7 @@ export async function process(html = '', config = {}) {
89
107
  expandLinkTag,
90
108
  postcssPlugin,
91
109
  fetchPlugin,
92
- components(
93
- merge(
94
- {
95
- expressions: merge(
96
- { locals },
97
- expressionsOptions,
98
- )
99
- },
100
- componentsUserOptions,
101
- defaultComponentsConfig
102
- )
103
- ),
110
+ components(componentsConfig),
104
111
  expandLinkTag,
105
112
  postcssPlugin,
106
113
  envTags(config.env),
@@ -162,9 +162,10 @@ export async function run(html = '', config = {}) {
162
162
  *
163
163
  * Add a base URL to relative paths.
164
164
  */
165
- if (get(config, 'baseURL', get(config, 'baseUrl'))) {
165
+ const baseConfig = get(config, 'baseURL', get(config, 'baseUrl'))
166
+ if (baseConfig) {
166
167
  posthtmlPlugins.push(
167
- baseUrl(get(config, 'baseURL', get(config, 'baseUrl', {})))
168
+ baseUrl(baseConfig)
168
169
  )
169
170
  }
170
171
 
package/types/config.d.ts CHANGED
@@ -53,12 +53,17 @@ export default interface Config {
53
53
  * ```
54
54
  * export default {
55
55
  * attributes: {
56
- * remove: ['width', 'height'],
56
+ * remove: [
57
+ * {
58
+ * name: 'width',
59
+ * value: '100', // or RegExp: /\d/
60
+ * },
61
+ * ], // or as array: ['width', 'height']
57
62
  * }
58
63
  * }
59
64
  * ```
60
65
  */
61
- remove?: Record<string, string[]>;
66
+ remove?: Array<string | { name: string; value: string | RegExp }>;
62
67
  }
63
68
 
64
69
  /**