@maizzle/framework 4.7.5 → 4.8.0

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,10 +1,10 @@
1
1
  {
2
2
  "name": "@maizzle/framework",
3
- "version": "4.7.5",
3
+ "version": "4.8.0",
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",
7
- "types": "src/index.d.ts",
7
+ "types": "types/index.d.ts",
8
8
  "bin": {
9
9
  "maizzle": "bin/maizzle"
10
10
  },
@@ -38,6 +38,7 @@
38
38
  },
39
39
  "files": [
40
40
  "src/**/*",
41
+ "types/**/*",
41
42
  "bin/*"
42
43
  ],
43
44
  "dependencies": {
@@ -59,7 +60,7 @@
59
60
  "postcss-merge-longhand": "^6.0.0",
60
61
  "posthtml": "^0.16.6",
61
62
  "posthtml-attrs-parser": "^0.1.1",
62
- "posthtml-base-url": "^2.0.0",
63
+ "posthtml-base-url": "^2.0.2",
63
64
  "posthtml-component": "^1.1.0",
64
65
  "posthtml-content": "^1.0.2",
65
66
  "posthtml-extend": "^0.6.0",
@@ -67,8 +68,8 @@
67
68
  "posthtml-fetch": "^3.0.0",
68
69
  "posthtml-markdownit": "^1.3.1",
69
70
  "posthtml-match-helper": "^1.0.3",
70
- "posthtml-mso": "^2.0.0",
71
- "posthtml-postcss-merge-longhand": "^2.0.1",
71
+ "posthtml-mso": "^2.0.1",
72
+ "posthtml-postcss-merge-longhand": "^2.1.0",
72
73
  "posthtml-safe-class-names": "^3.0.0",
73
74
  "posthtml-url-parameters": "^2.0.0",
74
75
  "pretty": "^2.0.0",
@@ -78,6 +79,7 @@
78
79
  "tailwindcss": "^3.2.7"
79
80
  },
80
81
  "devDependencies": {
82
+ "@types/browser-sync": "^2.29.0",
81
83
  "@types/js-beautify": "^1.14.0",
82
84
  "@types/markdown-it": "^13.0.0",
83
85
  "ava": "^5.2.0",
@@ -107,7 +107,7 @@ const serve = async (env = 'local', config = {}) => {
107
107
  let ext = ''
108
108
 
109
109
  if (Array.isArray(config.build.templates)) {
110
- const match = config.build.templates.find(template => template.source === path.parse(file).dir)
110
+ const match = config.build.templates.find(template => path.parse(file).dir.includes(path.normalize(template.source)))
111
111
  source = path.normalize(get(match, 'source'))
112
112
  dest = path.normalize(get(match, 'destination.path', 'build_local'))
113
113
  ext = get(match, 'destination.ext', 'html')
@@ -209,22 +209,26 @@ module.exports = async (env, spinner, config) => {
209
209
  }
210
210
  }
211
211
 
212
- const assets = {source: '', destination: 'assets', ...get(templateConfig, 'assets')}
213
-
214
- if (Array.isArray(assets.source)) {
215
- for await (const source of assets.source) {
216
- if (fs.existsSync(source)) {
212
+ const assets = Array.isArray(get(templateConfig, 'assets'))
213
+ ? get(templateConfig, 'assets')
214
+ : [{source: '', destination: 'assets', ...get(templateConfig, 'assets')}]
215
+
216
+ for await (const asset of assets) {
217
+ if (Array.isArray(asset.source)) {
218
+ for await (const source of asset.source) {
219
+ if (fs.existsSync(source)) {
220
+ await fs
221
+ .copy(source, path.join(templateConfig.destination.path, asset.destination))
222
+ .catch(error => spinner.warn(error.message))
223
+ }
224
+ }
225
+ } else {
226
+ if (fs.existsSync(asset.source)) {
217
227
  await fs
218
- .copy(source, path.join(templateConfig.destination.path, assets.destination))
228
+ .copy(asset.source, path.join(templateConfig.destination.path, asset.destination))
219
229
  .catch(error => spinner.warn(error.message))
220
230
  }
221
231
  }
222
- } else {
223
- if (fs.existsSync(assets.source)) {
224
- await fs
225
- .copy(assets.source, path.join(templateConfig.destination.path, assets.destination))
226
- .catch(error => spinner.warn(error.message))
227
- }
228
232
  }
229
233
 
230
234
  await glob(path.join(templateConfig.destination.path, '/**').replace(/\\/g, '/'))
@@ -0,0 +1,79 @@
1
+ export default interface BaseURLConfig {
2
+ /**
3
+ The URL to prepend.
4
+
5
+ @default undefined
6
+ */
7
+ url: string;
8
+
9
+ /**
10
+ Tags to apply the `url` to. When using this option, the `url` will only be prepended to the specified tags.
11
+
12
+ Maizzle uses a [custom set of tags](https://github.com/posthtml/posthtml-base-url/blob/main/lib/index.js#L6-L60) by default.
13
+
14
+ @example
15
+
16
+ Prepend `url` to all 'source'-like attribute values on image tags, like `src` and `srcset`:
17
+
18
+ ```
19
+ module.exports = {
20
+ baseURL: {
21
+ url: 'https://cdn.example.com/',
22
+ tags: ['img'],
23
+ },
24
+ }
25
+ ```
26
+
27
+ With more granular control:
28
+
29
+ ```
30
+ module.exports = {
31
+ baseURL: {
32
+ url: 'https://cdn.example.com/',
33
+ tags: {
34
+ img: {
35
+ src: true, // use the value of `url` above
36
+ srcset: 'https://bar.com/',
37
+ },
38
+ },
39
+ },
40
+ }
41
+ ```
42
+ */
43
+ tags?: string[] | Record<string, unknown>;
44
+
45
+ /**
46
+ Key-value pairs of attributes and the string to prepend to their existing value.
47
+
48
+ @default {}
49
+
50
+ @example
51
+
52
+ Prepend `https://example.com/` to all `data-url` attribute values:
53
+
54
+ ```
55
+ module.exports = {
56
+ baseURL: {
57
+ attributes: {
58
+ 'data-url': 'https://example.com/',
59
+ },
60
+ },
61
+ }
62
+ ```
63
+ */
64
+ attributes?: Record<string, unknown>;
65
+
66
+ /**
67
+ Whether the string defined in `url` should be prepended to `url()` values in CSS `<style>` tags.
68
+
69
+ @default true
70
+ */
71
+ styleTag?: boolean;
72
+
73
+ /**
74
+ Whether the string defined in `url` should be prepended to `url()` values in inline CSS.
75
+
76
+ @default true
77
+ */
78
+ inlineCss?: boolean;
79
+ }
@@ -0,0 +1,74 @@
1
+ import type LayoutsConfig from './layouts';
2
+ import type PostHTMLConfig from './posthtml';
3
+ import type TailwindConfig from './tailwind';
4
+ import type TemplatesConfig from './templates';
5
+ import type ComponentsConfig from './components';
6
+ import type {Options as BrowserSyncConfig} from 'browser-sync';
7
+
8
+ export default interface BuildConfig {
9
+ /**
10
+ Templates configuration.
11
+ */
12
+ templates: TemplatesConfig;
13
+
14
+ /**
15
+ Tailwind CSS configuration.
16
+ */
17
+ tailwind?: TailwindConfig;
18
+
19
+ /**
20
+ [DEPRECATED] Layouts configuration.
21
+ */
22
+ layouts?: LayoutsConfig;
23
+
24
+ /**
25
+ Components configuration.
26
+ */
27
+ components?: ComponentsConfig;
28
+
29
+ /**
30
+ PostHTML configuration.
31
+ */
32
+ posthtml?: PostHTMLConfig;
33
+
34
+ /**
35
+ Configure PostCSS
36
+ */
37
+ postcss?: {
38
+ /**
39
+ Additional PostCSS plugins that you would like to use.
40
+
41
+ @default []
42
+
43
+ @example
44
+ ```
45
+ const examplePlugin = require('postcss-example-plugin')
46
+ module.exports = {
47
+ build: {
48
+ postcss: {
49
+ plugins: [
50
+ examplePlugin()
51
+ ]
52
+ }
53
+ }
54
+ }
55
+ ```
56
+ */
57
+ plugins?: any[];
58
+ };
59
+
60
+ /**
61
+ Browsersync configuration.
62
+
63
+ When you run the `maizzle serve` command, Maizzle uses [Browsersync](https://browsersync.io/)
64
+ to start a local development server and open a directory listing of your emails in your default browser.
65
+ */
66
+ browsersync?: BrowserSyncConfig;
67
+
68
+ /**
69
+ Configure how build errors are handled when developing with the Maizzle CLI.
70
+
71
+ @default undefined
72
+ */
73
+ fail?: 'silent' | 'verbose';
74
+ }
@@ -0,0 +1,177 @@
1
+ export default interface ComponentsConfig {
2
+ /**
3
+ Root path where to look for folders containing component files.
4
+
5
+ @default './'
6
+ */
7
+ root?: string;
8
+
9
+ /**
10
+ Paths where to look for component files. Must be relative to `root`.
11
+
12
+ @default ['src/components', 'src/layouts', 'src/templates']
13
+ */
14
+ folders?: string[];
15
+
16
+ /**
17
+ Prefix to use for component tags.
18
+
19
+ @default 'x-'
20
+ */
21
+ tagPrefix?: string;
22
+
23
+ /**
24
+ Tag name to be used in HTML when using a component.
25
+
26
+ @default 'component'
27
+ */
28
+ tag?: string;
29
+
30
+ /**
31
+ Attribute name to be used when referencing a component via its path.
32
+
33
+ @default 'src'
34
+ */
35
+ attribute?: string;
36
+
37
+ /**
38
+ File extension that component files must use.
39
+ Any other files will be ignored and not be made available as components.
40
+
41
+ @default 'html'
42
+ */
43
+ fileExtension?: string;
44
+
45
+ /**
46
+ Name of the tag that will be replaced with the content that is passed to the component.
47
+
48
+ @default 'content'
49
+ */
50
+ yield?: string;
51
+
52
+ /**
53
+ Name of the slot tag, where the content will be injected.
54
+
55
+ @default 'slot'
56
+ */
57
+ slot?: string;
58
+
59
+ /**
60
+ Name of the fill tag, where the content to be injected is defined.
61
+
62
+ @default 'fill'
63
+ */
64
+ fill?: string;
65
+
66
+ /**
67
+ String to use as a separator between the slot tag and its name.
68
+
69
+ @default ':'
70
+ */
71
+ slotSeparator?: string;
72
+
73
+ /**
74
+ Tag name for pushing content to a stack.
75
+
76
+ @default 'push'
77
+ */
78
+ push?: string;
79
+
80
+ /**
81
+ Tag name for popping (rendering) content from a stack.
82
+
83
+ @default 'stack'
84
+ */
85
+ stack?: string;
86
+
87
+ /**
88
+ Name of the props attribute to use in the `<script>` tag of a component.
89
+
90
+ @default 'props'
91
+ */
92
+ propsScriptAttribute?: string;
93
+
94
+ /**
95
+ Name of the object that will be used to store the props of a component.
96
+
97
+ @default 'props'
98
+ */
99
+ propsContext?: string;
100
+
101
+ /**
102
+ Name of the attribute that will be used to pass props to a component as JSON.
103
+
104
+ @default 'locals'
105
+ */
106
+ propsAttribute?: string;
107
+
108
+ /**
109
+ Name of the key to use when retrieving props passed to a slot via `$slots.slotName.props`.
110
+
111
+ @default 'props'
112
+ */
113
+ propsSlot?: string;
114
+
115
+ /**
116
+ Configure [`posthtml-parser`](https://github.com/posthtml/posthtml-parser).
117
+
118
+ @default {recognizeSelfClosing:true}
119
+ */
120
+ parserOptions?: Record<string, any>;
121
+
122
+ /**
123
+ Configure [`posthtml-expressions`](https://github.com/posthtml/posthtml-expressions).
124
+
125
+ @default {} // custom object
126
+ */
127
+ expressions?: Record<any, any>;
128
+
129
+ /**
130
+ PostHTML plugins to apply to each parsed component.
131
+
132
+ @default []
133
+ */
134
+ plugins?: any[];
135
+
136
+ /**
137
+ Extra rules for the PostHTML plugin that is used by components to parse attributes.
138
+
139
+ @default {}
140
+ */
141
+ attrsParserRules?: Record<any, any>;
142
+
143
+ /**
144
+ In strict mode, an error will be thrown if a component cannot be rendered.
145
+
146
+ @default true
147
+ */
148
+ strict?: boolean;
149
+
150
+ /**
151
+ Utility methods to be passed to `<script props>` in a component.
152
+
153
+ @default {merge: _.mergeWith, template: _.template}
154
+ */
155
+ utilities?: Record<string, unknown>;
156
+
157
+ /**
158
+ Define additional attributes that should be preserved for specific HTML elements.
159
+
160
+ @default {}
161
+ */
162
+ elementAttributes?: Record<string, void>;
163
+
164
+ /**
165
+ Attributes that should be preserved on all elements in components.
166
+
167
+ @default ['data-*']
168
+ */
169
+ safelistAttributes?: string[];
170
+
171
+ /**
172
+ Attributes that should be removed from all elements in components.
173
+
174
+ @default []
175
+ */
176
+ blacklistAttributes?: string[];
177
+ }