@maizzle/framework 4.4.4 → 4.4.6

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.4",
3
+ "version": "4.4.6",
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",
@@ -92,7 +92,9 @@ module.exports = {
92
92
 
93
93
  if (buildTemplates) {
94
94
  const templateObjects = Array.isArray(buildTemplates) ? buildTemplates : [buildTemplates]
95
- const fileTypes = get(buildTemplates, 'filetypes', 'html')
95
+ const configFileTypes = get(buildTemplates, 'filetypes', ['html'])
96
+ const fileTypes = Array.isArray(configFileTypes) ? configFileTypes : configFileTypes.split('|')
97
+ const fileTypesPattern = fileTypes.length > 1 ? `{${fileTypes.join(',')}}` : fileTypes[0]
96
98
 
97
99
  templateObjects.forEach(template => {
98
100
  const source = get(template, 'source')
@@ -101,7 +103,7 @@ module.exports = {
101
103
  const sources = source(config)
102
104
 
103
105
  if (Array.isArray(sources)) {
104
- sources.map(s => tailwindConfig.content.files.push(`${s}/**/*.${fileTypes}`))
106
+ sources.map(s => tailwindConfig.content.files.push(`${s}/**/*.${fileTypesPattern}`))
105
107
  } else if (typeof sources === 'string') {
106
108
  tailwindConfig.content.files.push(sources)
107
109
  }
@@ -114,7 +116,7 @@ module.exports = {
114
116
 
115
117
  // Default behavior - directory sources as a string
116
118
  else {
117
- tailwindConfig.content.files.push(`${source}/**/*.${fileTypes}`)
119
+ tailwindConfig.content.files.push(`${source}/**/*.${fileTypesPattern}`)
118
120
  }
119
121
  })
120
122
  }
@@ -30,7 +30,7 @@ module.exports = async (html, config = {}, direct = false) => {
30
30
  config: merge({
31
31
  build: {
32
32
  tailwind: {
33
- config: get(config, 'build.tailwind.config', {})
33
+ config: get(config, 'build.tailwind.config', 'tailwind.config.js')
34
34
  }
35
35
  }
36
36
  }, maizzleConfig)
@@ -41,7 +41,11 @@ module.exports = async (html, config = {}, direct = false) => {
41
41
  posthtmlContent(filters)
42
42
  ]
43
43
 
44
- if (get(config, 'safeClassNames') !== false) {
44
+ /**
45
+ * Run `safeClassNames` in filters only when not when developing locally and
46
+ * `safeClassNames` is not explicitly disabled (set to `false`).
47
+ */
48
+ if (get(config, 'env') !== 'local' && get(config, 'safeClassNames') !== false) {
45
49
  posthtmlPlugins.push(safeClassNames({
46
50
  replacements: {
47
51
  '{': '{',
@@ -33,7 +33,7 @@ module.exports = async (html, config = {}, direct = false) => {
33
33
  {heads: '{{', tails: '}}'},
34
34
  {heads: '{%', tails: '%}'}
35
35
  ],
36
- whitelist: [...get(config, 'whitelist', []), ...safelist]
36
+ whitelist: get(config, 'whitelist', safelist)
37
37
  }
38
38
 
39
39
  const options = merge(defaultOptions, config)
@@ -1,20 +1,21 @@
1
1
  const posthtml = require('posthtml')
2
- const {get, merge} = require('lodash')
2
+ const {get, merge, isEmpty} = require('lodash')
3
3
  const safeClassNames = require('posthtml-safe-class-names')
4
4
  const defaultConfig = require('../generators/posthtml/defaultConfig')
5
5
 
6
6
  module.exports = async (html, config = {}, direct = false) => {
7
- const option = get(config, 'safeClassNames')
8
-
9
- if (option === false) {
10
- return html
11
- }
12
-
13
7
  /*
14
- * Setting it to `true` in the config will run `safeClassNames`
15
- * no matter the environment.
8
+ * Don't run when:
9
+ * - `config` is falsy or empty
10
+ * - developing locally and `safeClassNames` is not explicitly `true`
11
+ * - `safeClassNames` is explicitly `false`
16
12
  */
17
- if (config.env === 'local' && !option) {
13
+ if (
14
+ !config
15
+ || isEmpty(config)
16
+ || (get(config, 'env') === 'local' && get(config, 'safeClassNames') !== true)
17
+ || get(config, 'safeClassNames') === false
18
+ ) {
18
19
  return html
19
20
  }
20
21