@maizzle/framework 3.7.2 → 3.7.3
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/.github/workflows/nodejs.yml +29 -29
- package/package.json +84 -84
- package/src/generators/posthtml.js +60 -60
- package/src/generators/tailwindcss.js +84 -84
- package/src/transformers/base-image-url.js +9 -9
- package/src/transformers/index.js +57 -57
- package/src/transformers/six-hex.js +10 -10
- package/test/expected/transformers/base-image-url.html +7 -7
- package/test/fixtures/transformers/base-image-url.html +7 -7
- package/test/test-misc.js +8 -8
- package/test/test-tailwind.js +73 -73
- package/test/test-transformers.js +320 -320
- package/xo.config.js +19 -19
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
|
|
2
|
-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
|
|
3
|
-
|
|
4
|
-
name: Node.js CI
|
|
5
|
-
|
|
6
|
-
on:
|
|
7
|
-
push:
|
|
8
|
-
branches: [master]
|
|
9
|
-
pull_request:
|
|
10
|
-
branches: [master]
|
|
11
|
-
|
|
12
|
-
jobs:
|
|
13
|
-
build:
|
|
14
|
-
runs-on: ubuntu-latest
|
|
15
|
-
|
|
16
|
-
strategy:
|
|
17
|
-
matrix:
|
|
18
|
-
node-version: [12, 14, 16]
|
|
19
|
-
|
|
20
|
-
steps:
|
|
21
|
-
- uses: actions/checkout@v2
|
|
22
|
-
- name: Use Node.js ${{ matrix.node-version }}
|
|
23
|
-
uses: actions/setup-node@v1
|
|
24
|
-
with:
|
|
25
|
-
node-version: ${{ matrix.node-version }}
|
|
26
|
-
- run: npm install
|
|
27
|
-
- run: npm test
|
|
28
|
-
env:
|
|
29
|
-
CI: true
|
|
1
|
+
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
|
|
2
|
+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
|
|
3
|
+
|
|
4
|
+
name: Node.js CI
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches: [master]
|
|
9
|
+
pull_request:
|
|
10
|
+
branches: [master]
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
|
|
16
|
+
strategy:
|
|
17
|
+
matrix:
|
|
18
|
+
node-version: [12, 14, 16]
|
|
19
|
+
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v2
|
|
22
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
23
|
+
uses: actions/setup-node@v1
|
|
24
|
+
with:
|
|
25
|
+
node-version: ${{ matrix.node-version }}
|
|
26
|
+
- run: npm install
|
|
27
|
+
- run: npm test
|
|
28
|
+
env:
|
|
29
|
+
CI: true
|
package/package.json
CHANGED
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@maizzle/framework",
|
|
3
|
-
"version": "3.7.
|
|
4
|
-
"description": "Maizzle is a framework that helps you quickly build HTML emails with Tailwind CSS.",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"main": "src/index.js",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "https://github.com/maizzle/framework.git"
|
|
10
|
-
},
|
|
11
|
-
"bugs": "https://github.com/maizzle/framework/issues",
|
|
12
|
-
"homepage": "https://maizzle.com",
|
|
13
|
-
"author": "Cosmin Popovici (https://github.com/cossssmin)",
|
|
14
|
-
"keywords": [
|
|
15
|
-
"maizzle",
|
|
16
|
-
"tailwindcss",
|
|
17
|
-
"responsive-email",
|
|
18
|
-
"email-framework",
|
|
19
|
-
"email-template",
|
|
20
|
-
"email-marketing",
|
|
21
|
-
"email-campaigns",
|
|
22
|
-
"email-newsletter",
|
|
23
|
-
"email-boilerplate",
|
|
24
|
-
"html-emails"
|
|
25
|
-
],
|
|
26
|
-
"publishConfig": {
|
|
27
|
-
"access": "public"
|
|
28
|
-
},
|
|
29
|
-
"scripts": {
|
|
30
|
-
"test": "xo && nyc ava -s",
|
|
31
|
-
"style": "xo",
|
|
32
|
-
"release": "np"
|
|
33
|
-
},
|
|
34
|
-
"dependencies": {
|
|
35
|
-
"browser-sync": "^2.26.13",
|
|
36
|
-
"color-shorthand-hex-to-six-digit": "^3.0.2",
|
|
37
|
-
"email-comb": "^5.0.0",
|
|
38
|
-
"front-matter": "^4.0.0",
|
|
39
|
-
"fs-extra": "^10.0.0",
|
|
40
|
-
"glob-promise": "^4.1.0",
|
|
41
|
-
"html-crush": "^4.0.0",
|
|
42
|
-
"juice": "^8.0.0",
|
|
43
|
-
"lodash": "^4.17.20",
|
|
44
|
-
"ora": "^5.1.0",
|
|
45
|
-
"postcss": "^8.2.14",
|
|
46
|
-
"postcss-import": "^14.0.0",
|
|
47
|
-
"postcss-merge-longhand": "^5.0.1",
|
|
48
|
-
"posthtml": "^0.16.4",
|
|
49
|
-
"posthtml-attrs-parser": "^0.1.1",
|
|
50
|
-
"posthtml-content": "^0.0.3",
|
|
51
|
-
"posthtml-expressions": "^1.8.1",
|
|
52
|
-
"posthtml-extend": "^0.6.0",
|
|
53
|
-
"posthtml-extra-attributes": "^1.0.0",
|
|
54
|
-
"posthtml-fetch": "^2.0.0",
|
|
55
|
-
"posthtml-markdownit": "^1.2.2",
|
|
56
|
-
"posthtml-modules": "^0.7.4",
|
|
57
|
-
"posthtml-mso": "^1.0.2",
|
|
58
|
-
"posthtml-postcss-merge-longhand": "^1.0.2",
|
|
59
|
-
"posthtml-remove-attributes": "^1.0.0",
|
|
60
|
-
"posthtml-safe-class-names": "^1.0.4",
|
|
61
|
-
"posthtml-url-parameters": "^1.0.4",
|
|
62
|
-
"pretty": "^2.0.0",
|
|
63
|
-
"prevent-widows": "^1.0.2",
|
|
64
|
-
"query-string": "^7.0.0",
|
|
65
|
-
"string-strip-html": "^8.2.0",
|
|
66
|
-
"tailwindcss": "^2.2.2",
|
|
67
|
-
"tailwindcss-box-shadow": "^1.0.0"
|
|
68
|
-
},
|
|
69
|
-
"devDependencies": {
|
|
70
|
-
"autoprefixer": "^10.0.2",
|
|
71
|
-
"ava": "^3.13.0",
|
|
72
|
-
"np": "*",
|
|
73
|
-
"nyc": "^15.1.0",
|
|
74
|
-
"xo": "0.39.1"
|
|
75
|
-
},
|
|
76
|
-
"engines": {
|
|
77
|
-
"node": ">=12.13.0"
|
|
78
|
-
},
|
|
79
|
-
"ava": {
|
|
80
|
-
"files": [
|
|
81
|
-
"test/**/test*.js"
|
|
82
|
-
]
|
|
83
|
-
}
|
|
84
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@maizzle/framework",
|
|
3
|
+
"version": "3.7.3",
|
|
4
|
+
"description": "Maizzle is a framework that helps you quickly build HTML emails with Tailwind CSS.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "src/index.js",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/maizzle/framework.git"
|
|
10
|
+
},
|
|
11
|
+
"bugs": "https://github.com/maizzle/framework/issues",
|
|
12
|
+
"homepage": "https://maizzle.com",
|
|
13
|
+
"author": "Cosmin Popovici (https://github.com/cossssmin)",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"maizzle",
|
|
16
|
+
"tailwindcss",
|
|
17
|
+
"responsive-email",
|
|
18
|
+
"email-framework",
|
|
19
|
+
"email-template",
|
|
20
|
+
"email-marketing",
|
|
21
|
+
"email-campaigns",
|
|
22
|
+
"email-newsletter",
|
|
23
|
+
"email-boilerplate",
|
|
24
|
+
"html-emails"
|
|
25
|
+
],
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"test": "xo && nyc ava -s",
|
|
31
|
+
"style": "xo",
|
|
32
|
+
"release": "np"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"browser-sync": "^2.26.13",
|
|
36
|
+
"color-shorthand-hex-to-six-digit": "^3.0.2",
|
|
37
|
+
"email-comb": "^5.0.0",
|
|
38
|
+
"front-matter": "^4.0.0",
|
|
39
|
+
"fs-extra": "^10.0.0",
|
|
40
|
+
"glob-promise": "^4.1.0",
|
|
41
|
+
"html-crush": "^4.0.0",
|
|
42
|
+
"juice": "^8.0.0",
|
|
43
|
+
"lodash": "^4.17.20",
|
|
44
|
+
"ora": "^5.1.0",
|
|
45
|
+
"postcss": "^8.2.14",
|
|
46
|
+
"postcss-import": "^14.0.0",
|
|
47
|
+
"postcss-merge-longhand": "^5.0.1",
|
|
48
|
+
"posthtml": "^0.16.4",
|
|
49
|
+
"posthtml-attrs-parser": "^0.1.1",
|
|
50
|
+
"posthtml-content": "^0.0.3",
|
|
51
|
+
"posthtml-expressions": "^1.8.1",
|
|
52
|
+
"posthtml-extend": "^0.6.0",
|
|
53
|
+
"posthtml-extra-attributes": "^1.0.0",
|
|
54
|
+
"posthtml-fetch": "^2.0.0",
|
|
55
|
+
"posthtml-markdownit": "^1.2.2",
|
|
56
|
+
"posthtml-modules": "^0.7.4",
|
|
57
|
+
"posthtml-mso": "^1.0.2",
|
|
58
|
+
"posthtml-postcss-merge-longhand": "^1.0.2",
|
|
59
|
+
"posthtml-remove-attributes": "^1.0.0",
|
|
60
|
+
"posthtml-safe-class-names": "^1.0.4",
|
|
61
|
+
"posthtml-url-parameters": "^1.0.4",
|
|
62
|
+
"pretty": "^2.0.0",
|
|
63
|
+
"prevent-widows": "^1.0.2",
|
|
64
|
+
"query-string": "^7.0.0",
|
|
65
|
+
"string-strip-html": "^8.2.0",
|
|
66
|
+
"tailwindcss": "^2.2.2",
|
|
67
|
+
"tailwindcss-box-shadow": "^1.0.0"
|
|
68
|
+
},
|
|
69
|
+
"devDependencies": {
|
|
70
|
+
"autoprefixer": "^10.0.2",
|
|
71
|
+
"ava": "^3.13.0",
|
|
72
|
+
"np": "*",
|
|
73
|
+
"nyc": "^15.1.0",
|
|
74
|
+
"xo": "0.39.1"
|
|
75
|
+
},
|
|
76
|
+
"engines": {
|
|
77
|
+
"node": ">=12.13.0"
|
|
78
|
+
},
|
|
79
|
+
"ava": {
|
|
80
|
+
"files": [
|
|
81
|
+
"test/**/test*.js"
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
const fm = require('front-matter')
|
|
2
|
-
const posthtml = require('posthtml')
|
|
3
|
-
const {get, merge} = require('lodash')
|
|
4
|
-
const fetch = require('posthtml-fetch')
|
|
5
|
-
const layouts = require('posthtml-extend')
|
|
6
|
-
const modules = require('posthtml-modules')
|
|
7
|
-
const expressions = require('posthtml-expressions')
|
|
8
|
-
|
|
9
|
-
module.exports = async (html, config) => {
|
|
10
|
-
const layoutsOptions = get(config, 'build.layouts', {})
|
|
11
|
-
|
|
12
|
-
const fetchOptions = get(config, 'build.posthtml.fetch', {})
|
|
13
|
-
const fetchPlugin = fetch({...fetchOptions})
|
|
14
|
-
|
|
15
|
-
const modulesOptions = get(config, 'build.components', {})
|
|
16
|
-
// Fake `from` option so we can reference modules relatively
|
|
17
|
-
const modulesRoot = modulesOptions.root || './'
|
|
18
|
-
const modulesFrom = modulesOptions.from || `${modulesRoot}/fake`
|
|
19
|
-
|
|
20
|
-
const posthtmlOptions = get(config, 'build.posthtml.options', {})
|
|
21
|
-
const posthtmlPlugins = get(config, 'build.posthtml.plugins', [])
|
|
22
|
-
|
|
23
|
-
const expressionsOptions = merge({strictMode: false}, get(config, 'build.posthtml.expressions', {}))
|
|
24
|
-
|
|
25
|
-
const locals = merge(
|
|
26
|
-
get(expressionsOptions, 'locals', {}),
|
|
27
|
-
get(config, 'locals', {}),
|
|
28
|
-
{page: config}
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
return posthtml([
|
|
32
|
-
fetchPlugin,
|
|
33
|
-
layouts(
|
|
34
|
-
merge(
|
|
35
|
-
{
|
|
36
|
-
strict: false,
|
|
37
|
-
plugins: [
|
|
38
|
-
expressions({...expressionsOptions, locals})
|
|
39
|
-
]
|
|
40
|
-
},
|
|
41
|
-
layoutsOptions
|
|
42
|
-
)
|
|
43
|
-
),
|
|
44
|
-
modules({
|
|
45
|
-
parser: posthtmlOptions,
|
|
46
|
-
from: modulesFrom,
|
|
47
|
-
root: modulesRoot,
|
|
48
|
-
tag: 'component',
|
|
49
|
-
attribute: 'src',
|
|
50
|
-
plugins: [
|
|
51
|
-
fetchPlugin
|
|
52
|
-
],
|
|
53
|
-
locals,
|
|
54
|
-
...modulesOptions
|
|
55
|
-
}),
|
|
56
|
-
...posthtmlPlugins
|
|
57
|
-
])
|
|
58
|
-
.process(html, {...posthtmlOptions})
|
|
59
|
-
.then(result => fm(result.html).body)
|
|
60
|
-
}
|
|
1
|
+
const fm = require('front-matter')
|
|
2
|
+
const posthtml = require('posthtml')
|
|
3
|
+
const {get, merge} = require('lodash')
|
|
4
|
+
const fetch = require('posthtml-fetch')
|
|
5
|
+
const layouts = require('posthtml-extend')
|
|
6
|
+
const modules = require('posthtml-modules')
|
|
7
|
+
const expressions = require('posthtml-expressions')
|
|
8
|
+
|
|
9
|
+
module.exports = async (html, config) => {
|
|
10
|
+
const layoutsOptions = get(config, 'build.layouts', {})
|
|
11
|
+
|
|
12
|
+
const fetchOptions = get(config, 'build.posthtml.fetch', {})
|
|
13
|
+
const fetchPlugin = fetch({...fetchOptions})
|
|
14
|
+
|
|
15
|
+
const modulesOptions = get(config, 'build.components', {})
|
|
16
|
+
// Fake `from` option so we can reference modules relatively
|
|
17
|
+
const modulesRoot = modulesOptions.root || './'
|
|
18
|
+
const modulesFrom = modulesOptions.from || `${modulesRoot}/fake`
|
|
19
|
+
|
|
20
|
+
const posthtmlOptions = get(config, 'build.posthtml.options', {})
|
|
21
|
+
const posthtmlPlugins = get(config, 'build.posthtml.plugins', [])
|
|
22
|
+
|
|
23
|
+
const expressionsOptions = merge({strictMode: false}, get(config, 'build.posthtml.expressions', {}))
|
|
24
|
+
|
|
25
|
+
const locals = merge(
|
|
26
|
+
get(expressionsOptions, 'locals', {}),
|
|
27
|
+
get(config, 'locals', {}),
|
|
28
|
+
{page: config}
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
return posthtml([
|
|
32
|
+
fetchPlugin,
|
|
33
|
+
layouts(
|
|
34
|
+
merge(
|
|
35
|
+
{
|
|
36
|
+
strict: false,
|
|
37
|
+
plugins: [
|
|
38
|
+
expressions({...expressionsOptions, locals})
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
layoutsOptions
|
|
42
|
+
)
|
|
43
|
+
),
|
|
44
|
+
modules({
|
|
45
|
+
parser: posthtmlOptions,
|
|
46
|
+
from: modulesFrom,
|
|
47
|
+
root: modulesRoot,
|
|
48
|
+
tag: 'component',
|
|
49
|
+
attribute: 'src',
|
|
50
|
+
plugins: [
|
|
51
|
+
fetchPlugin
|
|
52
|
+
],
|
|
53
|
+
locals,
|
|
54
|
+
...modulesOptions
|
|
55
|
+
}),
|
|
56
|
+
...posthtmlPlugins
|
|
57
|
+
])
|
|
58
|
+
.process(html, {...posthtmlOptions})
|
|
59
|
+
.then(result => fm(result.html).body)
|
|
60
|
+
}
|
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
const path = require('path')
|
|
2
|
-
const fs = require('fs-extra')
|
|
3
|
-
const postcss = require('postcss')
|
|
4
|
-
const tailwindcss = require('tailwindcss')
|
|
5
|
-
const postcssImport = require('postcss-import')
|
|
6
|
-
const postcssNested = require('tailwindcss/nesting')
|
|
7
|
-
const {requireUncached} = require('../utils/helpers')
|
|
8
|
-
const mergeLonghand = require('postcss-merge-longhand')
|
|
9
|
-
const {get, isObject, isEmpty, merge} = require('lodash')
|
|
10
|
-
|
|
11
|
-
module.exports = {
|
|
12
|
-
compile: async (css = '', html = '', tailwindConfig = {}, maizzleConfig = {}) => {
|
|
13
|
-
tailwindConfig = (isObject(tailwindConfig) && !isEmpty(tailwindConfig)) ? tailwindConfig : get(maizzleConfig, 'build.tailwind.config', 'tailwind.config.js')
|
|
14
|
-
|
|
15
|
-
// Compute the Tailwind config to use
|
|
16
|
-
const userConfig = () => {
|
|
17
|
-
// If a custom config object was passed, use that
|
|
18
|
-
if (isObject(tailwindConfig) && !isEmpty(tailwindConfig)) {
|
|
19
|
-
return tailwindConfig
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Try loading a fresh tailwind.config.js, with fallback to an empty object.
|
|
24
|
-
* This will use the default Tailwind config (with rem units etc)
|
|
25
|
-
*/
|
|
26
|
-
try {
|
|
27
|
-
return requireUncached(path.resolve(process.cwd(), tailwindConfig))
|
|
28
|
-
} catch {
|
|
29
|
-
return {}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Merge user's Tailwind config on top of a 'base' config
|
|
34
|
-
const config = merge({
|
|
35
|
-
important: true,
|
|
36
|
-
purge: {
|
|
37
|
-
enabled: maizzleConfig.env !== 'local',
|
|
38
|
-
content: [
|
|
39
|
-
'src/**/*.*',
|
|
40
|
-
{raw: html}
|
|
41
|
-
],
|
|
42
|
-
options: get(maizzleConfig, 'purgeCSS', {})
|
|
43
|
-
},
|
|
44
|
-
corePlugins: {
|
|
45
|
-
animation: false,
|
|
46
|
-
backgroundOpacity: false,
|
|
47
|
-
borderOpacity: false,
|
|
48
|
-
boxShadow: false,
|
|
49
|
-
divideOpacity: false,
|
|
50
|
-
placeholderOpacity: false,
|
|
51
|
-
ringColor: false,
|
|
52
|
-
ringWidth: false,
|
|
53
|
-
ringOpacity: false,
|
|
54
|
-
ringOffsetColor: false,
|
|
55
|
-
textOpacity: false
|
|
56
|
-
},
|
|
57
|
-
plugins: []
|
|
58
|
-
}, userConfig())
|
|
59
|
-
|
|
60
|
-
// Merge user's Tailwind plugins with our default ones
|
|
61
|
-
config.plugins.push(require('tailwindcss-box-shadow'))
|
|
62
|
-
|
|
63
|
-
const userFilePath = get(maizzleConfig, 'build.tailwind.css', path.join(process.cwd(), 'src/css/tailwind.css'))
|
|
64
|
-
|
|
65
|
-
css = await fs.pathExists(userFilePath).then(async exists => {
|
|
66
|
-
if (exists) {
|
|
67
|
-
const userFileCSS = await fs.readFile(path.resolve(userFilePath), 'utf8')
|
|
68
|
-
return userFileCSS
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return css
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
return postcss([
|
|
75
|
-
postcssImport({path: userFilePath ? path.dirname(userFilePath) : []}),
|
|
76
|
-
postcssNested(),
|
|
77
|
-
tailwindcss(config),
|
|
78
|
-
maizzleConfig.env === 'local' ? () => {} : mergeLonghand(),
|
|
79
|
-
...get(maizzleConfig, 'build.postcss.plugins', [])
|
|
80
|
-
])
|
|
81
|
-
.process(css, {from: undefined})
|
|
82
|
-
.then(result => result.css)
|
|
83
|
-
}
|
|
84
|
-
}
|
|
1
|
+
const path = require('path')
|
|
2
|
+
const fs = require('fs-extra')
|
|
3
|
+
const postcss = require('postcss')
|
|
4
|
+
const tailwindcss = require('tailwindcss')
|
|
5
|
+
const postcssImport = require('postcss-import')
|
|
6
|
+
const postcssNested = require('tailwindcss/nesting')
|
|
7
|
+
const {requireUncached} = require('../utils/helpers')
|
|
8
|
+
const mergeLonghand = require('postcss-merge-longhand')
|
|
9
|
+
const {get, isObject, isEmpty, merge} = require('lodash')
|
|
10
|
+
|
|
11
|
+
module.exports = {
|
|
12
|
+
compile: async (css = '', html = '', tailwindConfig = {}, maizzleConfig = {}) => {
|
|
13
|
+
tailwindConfig = (isObject(tailwindConfig) && !isEmpty(tailwindConfig)) ? tailwindConfig : get(maizzleConfig, 'build.tailwind.config', 'tailwind.config.js')
|
|
14
|
+
|
|
15
|
+
// Compute the Tailwind config to use
|
|
16
|
+
const userConfig = () => {
|
|
17
|
+
// If a custom config object was passed, use that
|
|
18
|
+
if (isObject(tailwindConfig) && !isEmpty(tailwindConfig)) {
|
|
19
|
+
return tailwindConfig
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Try loading a fresh tailwind.config.js, with fallback to an empty object.
|
|
24
|
+
* This will use the default Tailwind config (with rem units etc)
|
|
25
|
+
*/
|
|
26
|
+
try {
|
|
27
|
+
return requireUncached(path.resolve(process.cwd(), tailwindConfig))
|
|
28
|
+
} catch {
|
|
29
|
+
return {}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Merge user's Tailwind config on top of a 'base' config
|
|
34
|
+
const config = merge({
|
|
35
|
+
important: true,
|
|
36
|
+
purge: {
|
|
37
|
+
enabled: maizzleConfig.env !== 'local',
|
|
38
|
+
content: [
|
|
39
|
+
'src/**/*.*',
|
|
40
|
+
{raw: html}
|
|
41
|
+
],
|
|
42
|
+
options: get(maizzleConfig, 'purgeCSS', {})
|
|
43
|
+
},
|
|
44
|
+
corePlugins: {
|
|
45
|
+
animation: false,
|
|
46
|
+
backgroundOpacity: false,
|
|
47
|
+
borderOpacity: false,
|
|
48
|
+
boxShadow: false,
|
|
49
|
+
divideOpacity: false,
|
|
50
|
+
placeholderOpacity: false,
|
|
51
|
+
ringColor: false,
|
|
52
|
+
ringWidth: false,
|
|
53
|
+
ringOpacity: false,
|
|
54
|
+
ringOffsetColor: false,
|
|
55
|
+
textOpacity: false
|
|
56
|
+
},
|
|
57
|
+
plugins: []
|
|
58
|
+
}, userConfig())
|
|
59
|
+
|
|
60
|
+
// Merge user's Tailwind plugins with our default ones
|
|
61
|
+
config.plugins.push(require('tailwindcss-box-shadow'))
|
|
62
|
+
|
|
63
|
+
const userFilePath = get(maizzleConfig, 'build.tailwind.css', path.join(process.cwd(), 'src/css/tailwind.css'))
|
|
64
|
+
|
|
65
|
+
css = await fs.pathExists(userFilePath).then(async exists => {
|
|
66
|
+
if (exists) {
|
|
67
|
+
const userFileCSS = await fs.readFile(path.resolve(userFilePath), 'utf8')
|
|
68
|
+
return userFileCSS + css
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return css
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
return postcss([
|
|
75
|
+
postcssImport({path: userFilePath ? path.dirname(userFilePath) : []}),
|
|
76
|
+
postcssNested(),
|
|
77
|
+
tailwindcss(config),
|
|
78
|
+
maizzleConfig.env === 'local' ? () => {} : mergeLonghand(),
|
|
79
|
+
...get(maizzleConfig, 'build.postcss.plugins', [])
|
|
80
|
+
])
|
|
81
|
+
.process(css, {from: undefined})
|
|
82
|
+
.then(result => result.css)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
module.exports = async (html, config = {}, direct = false) => {
|
|
2
|
-
const url = direct ? config : config.baseImageURL
|
|
3
|
-
|
|
4
|
-
if (url) {
|
|
5
|
-
return html.replace(/([^"'=\s(]+\.(?:jpe?g|a?png|avif|gif|svg|webp|jfif|pjpeg|pjp))/gi, url + '$1')
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
return html
|
|
9
|
-
}
|
|
1
|
+
module.exports = async (html, config = {}, direct = false) => {
|
|
2
|
+
const url = direct ? config : config.baseImageURL
|
|
3
|
+
|
|
4
|
+
if (url) {
|
|
5
|
+
return html.replace(/([^"'=\s(]+\.(?:jpe?g|a?png|avif|gif|svg|webp|jfif|pjpeg|pjp))/gi, url + '$1')
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
return html
|
|
9
|
+
}
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
const inline = require('./inline')
|
|
2
|
-
const minify = require('./minify')
|
|
3
|
-
const markdown = require('./markdown')
|
|
4
|
-
const prettify = require('./prettify')
|
|
5
|
-
const ensureSixHEX = require('./six-hex')
|
|
6
|
-
const addURLParams = require('./url-params')
|
|
7
|
-
const transformContents = require('./transform')
|
|
8
|
-
const preventWidows = require('./prevent-widows')
|
|
9
|
-
const replaceStrings = require('./replace-strings')
|
|
10
|
-
const safeClassNames = require('./safe-class-names')
|
|
11
|
-
const applyBaseImageUrl = require('./base-image-url')
|
|
12
|
-
const removeUnusedCSS = require('./remove-unused-css')
|
|
13
|
-
const removeAttributes = require('./remove-attributes')
|
|
14
|
-
const attributeToStyle = require('./attribute-to-style')
|
|
15
|
-
const removeInlineSizes = require('./remove-inline-sizes')
|
|
16
|
-
const applyExtraAttributes = require('./extra-attributes')
|
|
17
|
-
const removeInlineBgColor = require('./remove-inline-bgcolor')
|
|
18
|
-
|
|
19
|
-
exports.process = async (html, config) => {
|
|
20
|
-
html = await safeClassNames(html, config)
|
|
21
|
-
html = await transformContents(html, config)
|
|
22
|
-
html = await markdown(html, config)
|
|
23
|
-
html = await preventWidows(html, config)
|
|
24
|
-
html = await attributeToStyle(html, config)
|
|
25
|
-
html = await inline(html, config)
|
|
26
|
-
html = await removeUnusedCSS(html, config)
|
|
27
|
-
html = await removeInlineSizes(html, config)
|
|
28
|
-
html = await removeInlineBgColor(html, config)
|
|
29
|
-
html = await removeAttributes(html, config)
|
|
30
|
-
html = await applyExtraAttributes(html, config)
|
|
31
|
-
html = await applyBaseImageUrl(html, config)
|
|
32
|
-
html = await addURLParams(html, config)
|
|
33
|
-
html = await ensureSixHEX(html, config)
|
|
34
|
-
html = await prettify(html, config)
|
|
35
|
-
html = await minify(html, config)
|
|
36
|
-
html = await replaceStrings(html, config)
|
|
37
|
-
|
|
38
|
-
return html
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
exports.inlineCSS = (html, config) => inline(html, config, true)
|
|
42
|
-
exports.minify = (html, config) => minify(html, config, true)
|
|
43
|
-
exports.markdown = (html, config) => markdown(html, config, true)
|
|
44
|
-
exports.prettify = (html, config) => prettify(html, config, true)
|
|
45
|
-
exports.ensureSixHEX = (html, config) => ensureSixHEX(html, config)
|
|
46
|
-
exports.addURLParams = (html, config) => addURLParams(html, config, true)
|
|
47
|
-
exports.transformContents = (html, config) => transformContents(html, config, true)
|
|
48
|
-
exports.preventWidows = (html, config) => preventWidows(html, config, true)
|
|
49
|
-
exports.replaceStrings = (html, config) => replaceStrings(html, config, true)
|
|
50
|
-
exports.safeClassNames = (html, config) => safeClassNames(html, config, true)
|
|
51
|
-
exports.applyBaseImageUrl = (html, config) => applyBaseImageUrl(html, config, true)
|
|
52
|
-
exports.removeUnusedCSS = (html, config) => removeUnusedCSS(html, config, true)
|
|
53
|
-
exports.removeAttributes = (html, config) => removeAttributes(html, config, true)
|
|
54
|
-
exports.removeInlineSizes = (html, config) => removeInlineSizes(html, config, true)
|
|
55
|
-
exports.applyExtraAttributes = (html, config) => applyExtraAttributes(html, config, true)
|
|
56
|
-
exports.removeInlineBgColor = (html, config) => removeInlineBgColor(html, config, true)
|
|
57
|
-
exports.attributeToStyle = (html, config) => attributeToStyle(html, config, true)
|
|
1
|
+
const inline = require('./inline')
|
|
2
|
+
const minify = require('./minify')
|
|
3
|
+
const markdown = require('./markdown')
|
|
4
|
+
const prettify = require('./prettify')
|
|
5
|
+
const ensureSixHEX = require('./six-hex')
|
|
6
|
+
const addURLParams = require('./url-params')
|
|
7
|
+
const transformContents = require('./transform')
|
|
8
|
+
const preventWidows = require('./prevent-widows')
|
|
9
|
+
const replaceStrings = require('./replace-strings')
|
|
10
|
+
const safeClassNames = require('./safe-class-names')
|
|
11
|
+
const applyBaseImageUrl = require('./base-image-url')
|
|
12
|
+
const removeUnusedCSS = require('./remove-unused-css')
|
|
13
|
+
const removeAttributes = require('./remove-attributes')
|
|
14
|
+
const attributeToStyle = require('./attribute-to-style')
|
|
15
|
+
const removeInlineSizes = require('./remove-inline-sizes')
|
|
16
|
+
const applyExtraAttributes = require('./extra-attributes')
|
|
17
|
+
const removeInlineBgColor = require('./remove-inline-bgcolor')
|
|
18
|
+
|
|
19
|
+
exports.process = async (html, config) => {
|
|
20
|
+
html = await safeClassNames(html, config)
|
|
21
|
+
html = await transformContents(html, config)
|
|
22
|
+
html = await markdown(html, config)
|
|
23
|
+
html = await preventWidows(html, config)
|
|
24
|
+
html = await attributeToStyle(html, config)
|
|
25
|
+
html = await inline(html, config)
|
|
26
|
+
html = await removeUnusedCSS(html, config)
|
|
27
|
+
html = await removeInlineSizes(html, config)
|
|
28
|
+
html = await removeInlineBgColor(html, config)
|
|
29
|
+
html = await removeAttributes(html, config)
|
|
30
|
+
html = await applyExtraAttributes(html, config)
|
|
31
|
+
html = await applyBaseImageUrl(html, config)
|
|
32
|
+
html = await addURLParams(html, config)
|
|
33
|
+
html = await ensureSixHEX(html, config)
|
|
34
|
+
html = await prettify(html, config)
|
|
35
|
+
html = await minify(html, config)
|
|
36
|
+
html = await replaceStrings(html, config)
|
|
37
|
+
|
|
38
|
+
return html
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
exports.inlineCSS = (html, config) => inline(html, config, true)
|
|
42
|
+
exports.minify = (html, config) => minify(html, config, true)
|
|
43
|
+
exports.markdown = (html, config) => markdown(html, config, true)
|
|
44
|
+
exports.prettify = (html, config) => prettify(html, config, true)
|
|
45
|
+
exports.ensureSixHEX = (html, config) => ensureSixHEX(html, config)
|
|
46
|
+
exports.addURLParams = (html, config) => addURLParams(html, config, true)
|
|
47
|
+
exports.transformContents = (html, config) => transformContents(html, config, true)
|
|
48
|
+
exports.preventWidows = (html, config) => preventWidows(html, config, true)
|
|
49
|
+
exports.replaceStrings = (html, config) => replaceStrings(html, config, true)
|
|
50
|
+
exports.safeClassNames = (html, config) => safeClassNames(html, config, true)
|
|
51
|
+
exports.applyBaseImageUrl = (html, config) => applyBaseImageUrl(html, config, true)
|
|
52
|
+
exports.removeUnusedCSS = (html, config) => removeUnusedCSS(html, config, true)
|
|
53
|
+
exports.removeAttributes = (html, config) => removeAttributes(html, config, true)
|
|
54
|
+
exports.removeInlineSizes = (html, config) => removeInlineSizes(html, config, true)
|
|
55
|
+
exports.applyExtraAttributes = (html, config) => applyExtraAttributes(html, config, true)
|
|
56
|
+
exports.removeInlineBgColor = (html, config) => removeInlineBgColor(html, config, true)
|
|
57
|
+
exports.attributeToStyle = (html, config) => attributeToStyle(html, config, true)
|