@maizzle/framework 4.4.0-beta.13 → 4.4.0-beta.14

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.0-beta.13",
3
+ "version": "4.4.0-beta.14",
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",
@@ -8,6 +8,22 @@ const {requireUncached} = require('../utils/helpers')
8
8
  const mergeLonghand = require('postcss-merge-longhand')
9
9
  const {get, isObject, isEmpty, merge} = require('lodash')
10
10
 
11
+ const addImportantPlugin = () => {
12
+ return {
13
+ postcssPlugin: 'add-important',
14
+ Rule(rule) {
15
+ const shouldAddImportant = get(rule, 'raws.tailwind.layer') === 'variants'
16
+ || get(rule, 'parent.type') === 'atrule'
17
+
18
+ if (shouldAddImportant) {
19
+ rule.walkDecls(decl => {
20
+ decl.important = true
21
+ })
22
+ }
23
+ }
24
+ }
25
+ }
26
+
11
27
  module.exports = {
12
28
  compile: async ({css = '', html = '', config = {}}) => {
13
29
  // Compute the Tailwind config to use
@@ -34,25 +50,30 @@ module.exports = {
34
50
  const layoutsRoot = get(config, 'build.layouts.root')
35
51
  const componentsRoot = get(config, 'build.components.root')
36
52
 
53
+ const layoutsPath = typeof layoutsRoot === 'string' && layoutsRoot ?
54
+ `${layoutsRoot}/**/*.html`.replace(/\/\//g, '/') :
55
+ './src/layouts/**/*.html'
56
+
57
+ const componentsPath = typeof componentsRoot === 'string' && componentsRoot ?
58
+ `${componentsRoot}/**/*.html`.replace(/\/\//g, '/') :
59
+ './src/components/**/*.html'
60
+
37
61
  const tailwindConfig = merge({
38
- important: true,
39
62
  content: {
40
63
  files: [
41
- typeof layoutsRoot === 'string' && layoutsRoot ?
42
- `${layoutsRoot}/**/*.html`.replace(/\/\//g, '/') :
43
- './src/layouts/**/*.html',
44
- typeof componentsRoot === 'string' && componentsRoot ?
45
- `${componentsRoot}/**/*.html`.replace(/\/\//g, '/') :
46
- './src/components/**/*.html',
64
+ layoutsPath,
65
+ componentsPath,
47
66
  {raw: html, extension: 'html'}
48
67
  ]
49
68
  }
50
69
  }, userConfig(config))
51
70
 
52
- // Add back the `{raw: html}` option if user provided own config
71
+ // If `content` is an array, add it to `content.files`
53
72
  if (Array.isArray(tailwindConfig.content)) {
54
73
  tailwindConfig.content = {
55
74
  files: [
75
+ layoutsPath,
76
+ componentsPath,
56
77
  ...tailwindConfig.content,
57
78
  {raw: html, extension: 'html'}
58
79
  ]
@@ -99,6 +120,7 @@ module.exports = {
99
120
  const toProcess = [
100
121
  postcssNested(),
101
122
  tailwindcss(tailwindConfig),
123
+ get(tailwindConfig, 'important') === false ? () => {} : addImportantPlugin(),
102
124
  get(config, 'shorthandCSS', get(config, 'shorthandInlineCSS')) === true ?
103
125
  mergeLonghand() :
104
126
  () => {},