@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,10 +1,10 @@
|
|
|
1
|
-
const {get} = require('lodash')
|
|
2
|
-
const {conv} = require('color-shorthand-hex-to-six-digit')
|
|
3
|
-
|
|
4
|
-
module.exports = async (html, config = {}) => {
|
|
5
|
-
if (get(config, 'sixHex') === false) {
|
|
6
|
-
return html
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
return conv(html)
|
|
10
|
-
}
|
|
1
|
+
const {get} = require('lodash')
|
|
2
|
+
const {conv} = require('color-shorthand-hex-to-six-digit')
|
|
3
|
+
|
|
4
|
+
module.exports = async (html, config = {}) => {
|
|
5
|
+
if (get(config, 'sixHex') === false) {
|
|
6
|
+
return html
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return conv(html)
|
|
10
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
<div style="background-image: url('https://example.com/foo/bar.jpg')">
|
|
2
|
-
<img src="https://example.com/logo.png" srcset="https://example.com/assets/logo.png 1x, https://example.com/assets/logo@2x.png 2x">
|
|
3
|
-
</div>
|
|
4
|
-
|
|
5
|
-
<div style="background: url(https://example.com/foo/bar.jpg)">
|
|
6
|
-
<img background="https://example.com/example.jpg" srcset="https://example.com/example.jpg 1x, https://example.com/example@2x.jpg 2x">
|
|
7
|
-
</div>
|
|
1
|
+
<div style="background-image: url('https://example.com/foo/bar.jpg')">
|
|
2
|
+
<img src="https://example.com/logo.png" srcset="https://example.com/assets/logo.png 1x, https://example.com/assets/logo@2x.png 2x">
|
|
3
|
+
</div>
|
|
4
|
+
|
|
5
|
+
<div style="background: url(https://example.com/foo/bar.jpg)">
|
|
6
|
+
<img background="https://example.com/example.jpg" srcset="https://example.com/example.jpg 1x, https://example.com/example@2x.jpg 2x">
|
|
7
|
+
</div>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
<div style="background-image: url('foo/bar.jpg')">
|
|
2
|
-
<img src="logo.png" srcset="assets/logo.png 1x, assets/logo@2x.png 2x">
|
|
3
|
-
</div>
|
|
4
|
-
|
|
5
|
-
<div style="background: url(foo/bar.jpg)">
|
|
6
|
-
<img background="example.jpg" srcset="example.jpg 1x, example@2x.jpg 2x">
|
|
7
|
-
</div>
|
|
1
|
+
<div style="background-image: url('foo/bar.jpg')">
|
|
2
|
+
<img src="logo.png" srcset="assets/logo.png 1x, assets/logo@2x.png 2x">
|
|
3
|
+
</div>
|
|
4
|
+
|
|
5
|
+
<div style="background: url(foo/bar.jpg)">
|
|
6
|
+
<img background="example.jpg" srcset="example.jpg 1x, example@2x.jpg 2x">
|
|
7
|
+
</div>
|
package/test/test-misc.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const test = require('ava')
|
|
2
|
-
const path = require('path')
|
|
3
|
-
const {requireUncached} = require('../src/utils/helpers')
|
|
4
|
-
|
|
5
|
-
test('requires an uncached module', t => {
|
|
6
|
-
const helpers = requireUncached(path.resolve(process.cwd(), 'src/utils/helpers'))
|
|
7
|
-
t.is(typeof helpers.requireUncached, 'function')
|
|
8
|
-
})
|
|
1
|
+
const test = require('ava')
|
|
2
|
+
const path = require('path')
|
|
3
|
+
const {requireUncached} = require('../src/utils/helpers')
|
|
4
|
+
|
|
5
|
+
test('requires an uncached module', t => {
|
|
6
|
+
const helpers = requireUncached(path.resolve(process.cwd(), 'src/utils/helpers'))
|
|
7
|
+
t.is(typeof helpers.requireUncached, 'function')
|
|
8
|
+
})
|
package/test/test-tailwind.js
CHANGED
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
const test = require('ava')
|
|
2
|
-
const Tailwind = require('../src/generators/tailwindcss')
|
|
3
|
-
|
|
4
|
-
test('uses Tailwind defaults if no config specified', async t => {
|
|
5
|
-
const css = await Tailwind.compile('@tailwind utilities', '<p class="xl:z-0"></p>', {}, {env: 'production'})
|
|
6
|
-
|
|
7
|
-
t.not(css, undefined)
|
|
8
|
-
t.true(css.includes('.xl\\:z-0'))
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
test('uses CSS file provided in environment config', async t => {
|
|
12
|
-
const config = {
|
|
13
|
-
env: 'production',
|
|
14
|
-
build: {
|
|
15
|
-
tailwind: {
|
|
16
|
-
css: './test/stubs/main.css'
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const css = await Tailwind.compile('', '<div class="text-center foo">test</div>', {}, config)
|
|
22
|
-
|
|
23
|
-
t.not(css, undefined)
|
|
24
|
-
t.true(css.includes('.text-center'))
|
|
25
|
-
t.true(css.includes('.foo'))
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
test('uses purgeCSS options provided in the maizzle config', async t => {
|
|
29
|
-
const arrayConfig = {
|
|
30
|
-
purgeCSS: {
|
|
31
|
-
safelist: ['z-10'],
|
|
32
|
-
blocklist: ['text-center']
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const objectConfig = {
|
|
37
|
-
purgeCSS: {
|
|
38
|
-
safelist: {
|
|
39
|
-
standard: ['z-10']
|
|
40
|
-
},
|
|
41
|
-
blocklist: ['text-center']
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const css1 = await Tailwind.compile('@tailwind utilities', '<div class="z-0 text-center"></div>', {}, arrayConfig)
|
|
46
|
-
const css2 = await Tailwind.compile('@tailwind utilities', '<div class="z-0 text-center"></div>', {}, objectConfig)
|
|
47
|
-
|
|
48
|
-
t.true(css1.includes('.z-0'))
|
|
49
|
-
t.true(css1.includes('.z-10'))
|
|
50
|
-
t.false(css1.includes('.text-center'))
|
|
51
|
-
|
|
52
|
-
t.true(css2.includes('.z-0'))
|
|
53
|
-
t.true(css2.includes('.z-10'))
|
|
54
|
-
t.false(css2.includes('.text-center'))
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
test('uses postcss plugins from the maizzle config when compiling from string', async t => {
|
|
58
|
-
const maizzleConfig = {
|
|
59
|
-
env: 'production',
|
|
60
|
-
build: {
|
|
61
|
-
postcss: {
|
|
62
|
-
plugins: [
|
|
63
|
-
require('autoprefixer')({overrideBrowserslist: ['> 0.1%']})
|
|
64
|
-
]
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const css = await Tailwind.compile('.test {transform: scale(0.5)}', '<div class="test">Test</a>', {}, maizzleConfig)
|
|
70
|
-
|
|
71
|
-
t.not(css, undefined)
|
|
72
|
-
t.is(css.trim(), '/* purgecss start ignore */\n\n.test {\n -webkit-transform: scale(0.5);\n -ms-transform: scale(0.5);\n transform: scale(0.5)\n}\n\n/* purgecss end ignore */')
|
|
73
|
-
})
|
|
1
|
+
const test = require('ava')
|
|
2
|
+
const Tailwind = require('../src/generators/tailwindcss')
|
|
3
|
+
|
|
4
|
+
test('uses Tailwind defaults if no config specified', async t => {
|
|
5
|
+
const css = await Tailwind.compile('@tailwind utilities', '<p class="xl:z-0"></p>', {}, {env: 'production'})
|
|
6
|
+
|
|
7
|
+
t.not(css, undefined)
|
|
8
|
+
t.true(css.includes('.xl\\:z-0'))
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
test('uses CSS file provided in environment config', async t => {
|
|
12
|
+
const config = {
|
|
13
|
+
env: 'production',
|
|
14
|
+
build: {
|
|
15
|
+
tailwind: {
|
|
16
|
+
css: './test/stubs/main.css'
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const css = await Tailwind.compile('', '<div class="text-center foo">test</div>', {}, config)
|
|
22
|
+
|
|
23
|
+
t.not(css, undefined)
|
|
24
|
+
t.true(css.includes('.text-center'))
|
|
25
|
+
t.true(css.includes('.foo'))
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
test('uses purgeCSS options provided in the maizzle config', async t => {
|
|
29
|
+
const arrayConfig = {
|
|
30
|
+
purgeCSS: {
|
|
31
|
+
safelist: ['z-10'],
|
|
32
|
+
blocklist: ['text-center']
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const objectConfig = {
|
|
37
|
+
purgeCSS: {
|
|
38
|
+
safelist: {
|
|
39
|
+
standard: ['z-10']
|
|
40
|
+
},
|
|
41
|
+
blocklist: ['text-center']
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const css1 = await Tailwind.compile('@tailwind utilities', '<div class="z-0 text-center"></div>', {}, arrayConfig)
|
|
46
|
+
const css2 = await Tailwind.compile('@tailwind utilities', '<div class="z-0 text-center"></div>', {}, objectConfig)
|
|
47
|
+
|
|
48
|
+
t.true(css1.includes('.z-0'))
|
|
49
|
+
t.true(css1.includes('.z-10'))
|
|
50
|
+
t.false(css1.includes('.text-center'))
|
|
51
|
+
|
|
52
|
+
t.true(css2.includes('.z-0'))
|
|
53
|
+
t.true(css2.includes('.z-10'))
|
|
54
|
+
t.false(css2.includes('.text-center'))
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
test('uses postcss plugins from the maizzle config when compiling from string', async t => {
|
|
58
|
+
const maizzleConfig = {
|
|
59
|
+
env: 'production',
|
|
60
|
+
build: {
|
|
61
|
+
postcss: {
|
|
62
|
+
plugins: [
|
|
63
|
+
require('autoprefixer')({overrideBrowserslist: ['> 0.1%']})
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const css = await Tailwind.compile('.test {transform: scale(0.5)}', '<div class="test">Test</a>', {}, maizzleConfig)
|
|
70
|
+
|
|
71
|
+
t.not(css, undefined)
|
|
72
|
+
t.is(css.trim(), '/* purgecss start ignore */\n\n.test {\n -webkit-transform: scale(0.5);\n -ms-transform: scale(0.5);\n transform: scale(0.5)\n}\n\n/* purgecss end ignore */')
|
|
73
|
+
})
|