@maizzle/framework 4.0.0-alpha.7 → 4.0.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/.github/media/logo-dark.svg +1 -0
- package/.github/media/logo-light.svg +1 -0
- package/.github/workflows/nodejs.yml +1 -1
- package/README.md +42 -35
- package/bin/maizzle +3 -0
- package/package.json +12 -7
- package/src/commands/serve.js +31 -18
- package/src/generators/output/to-string.js +2 -6
- package/src/generators/postcss.js +29 -0
- package/src/generators/posthtml.js +66 -61
- package/src/generators/tailwindcss.js +1 -1
- package/src/index.js +17 -13
- package/src/transformers/baseUrl.js +33 -9
- package/src/transformers/filters/defaultFilters.js +126 -0
- package/src/transformers/filters/index.js +55 -0
- package/src/transformers/index.js +15 -9
- package/src/transformers/inlineCss.js +1 -14
- package/src/transformers/minify.js +1 -1
- package/src/transformers/prettify.js +16 -9
- package/src/transformers/removeInlineBackgroundColor.js +1 -1
- package/src/transformers/removeInlinedSelectors.js +70 -0
- package/src/transformers/removeUnusedCss.js +40 -20
- package/src/transformers/shorthandInlineCSS.js +19 -0
- package/src/transformers/sixHex.js +24 -1
- package/test/expected/posthtml/component.html +13 -0
- package/test/expected/{inheritance.html → posthtml/extend-template.html} +2 -2
- package/test/expected/posthtml/fetch.html +5 -0
- package/test/expected/posthtml/layout.html +3 -0
- package/test/expected/transformers/atimport-in-style.html +15 -0
- package/test/expected/transformers/{base-image-url.html → base-url.html} +18 -2
- package/test/expected/transformers/filters.html +81 -0
- package/test/expected/transformers/preserve-transform-css.html +36 -0
- package/test/expected/useConfig.html +9 -9
- package/test/fixtures/basic.html +6 -6
- package/test/fixtures/posthtml/component.html +19 -0
- package/test/fixtures/{inheritance.html → posthtml/extend-template.html} +7 -7
- package/test/fixtures/posthtml/fetch.html +9 -0
- package/test/fixtures/posthtml/layout.html +11 -0
- package/test/fixtures/transformers/atimport-in-style.html +11 -0
- package/test/fixtures/transformers/{base-image-url.html → base-url.html} +18 -2
- package/test/fixtures/transformers/filters.html +87 -0
- package/test/fixtures/transformers/preserve-transform-css.html +25 -0
- package/test/fixtures/useConfig.html +9 -9
- package/test/stubs/components/component.html +5 -0
- package/test/stubs/data.json +14 -0
- package/test/stubs/layouts/basic.html +1 -0
- package/test/stubs/{layout.html → layouts/full.html} +0 -0
- package/test/stubs/{layout-basic.html → layouts/template.html} +5 -5
- package/test/stubs/post.css +6 -0
- package/test/stubs/tailwind/{preserve.html → content-source.html} +0 -0
- package/test/stubs/tailwind/tailwind.css +3 -0
- package/test/stubs/template.html +10 -10
- package/test/stubs/templates/1.html +1 -1
- package/test/stubs/templates/2.test +1 -0
- package/test/test-config.js +19 -19
- package/test/test-postcss.js +8 -0
- package/test/test-posthtml.js +72 -0
- package/test/{test-tailwind.js → test-tailwindcss.js} +117 -117
- package/test/test-todisk.js +511 -497
- package/test/test-tostring.js +32 -16
- package/test/test-transformers.js +510 -343
- package/src/transformers/transform.js +0 -22
- package/test/expected/transformers/transform-postcss.html +0 -19
- package/test/stubs/templates/2.html +0 -1
- package/test/stubs/templates/3.mzl +0 -1
|
@@ -1,117 +1,117 @@
|
|
|
1
|
-
const test = require('ava')
|
|
2
|
-
const ora = require('ora')
|
|
3
|
-
const Tailwind = require('../src/generators/tailwindcss')
|
|
4
|
-
|
|
5
|
-
test('throws on compile error', async t => {
|
|
6
|
-
await t.throwsAsync(async () => {
|
|
7
|
-
const spinner = ora('Compiling Tailwind CSS...').start()
|
|
8
|
-
await Tailwind.compile('.test {@apply inexistent;}', '<div class="test">Test</a>', {}, {}, spinner)
|
|
9
|
-
}, {instanceOf: Error, message: 'Tailwind CSS compilation failed'})
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
test('uses
|
|
13
|
-
const css = await Tailwind.compile(
|
|
14
|
-
'@tailwind utilities;',
|
|
15
|
-
'<p class="xl:z-0"></p>',
|
|
16
|
-
{},
|
|
17
|
-
{env: 'production'}
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
t.not(css, undefined)
|
|
21
|
-
t.true(css.includes('.xl\\:z-0'))
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
test('uses
|
|
25
|
-
const config = {
|
|
26
|
-
env: 'production',
|
|
27
|
-
build: {
|
|
28
|
-
tailwind: {
|
|
29
|
-
css: './test/stubs/main.css'
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const css = await Tailwind.compile('', '<div class="text-center foo">test</div>', {}, config)
|
|
35
|
-
|
|
36
|
-
t.not(css, undefined)
|
|
37
|
-
t.true(css.includes('.text-center'))
|
|
38
|
-
t.true(css.includes('.foo'))
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
test('works with custom `content` sources', async t => {
|
|
42
|
-
const css = await Tailwind.compile(
|
|
43
|
-
'@tailwind utilities;',
|
|
44
|
-
'<div class="hidden"></div>',
|
|
45
|
-
{
|
|
46
|
-
content: ['./test/stubs/tailwind/*.*']
|
|
47
|
-
}
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
t.true(css.includes('.hidden'))
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
test('works with custom `files` sources', async t => {
|
|
54
|
-
const css = await Tailwind.compile(
|
|
55
|
-
'@tailwind utilities;',
|
|
56
|
-
'<div></div>',
|
|
57
|
-
{
|
|
58
|
-
content: {
|
|
59
|
-
files: ['./test/stubs/tailwind/*.*']
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
t.true(css.includes('.hidden'))
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
test('uses maizzle template path as content source', async t => {
|
|
68
|
-
const css = await Tailwind.compile(
|
|
69
|
-
'@tailwind utilities;',
|
|
70
|
-
'<div></div>',
|
|
71
|
-
{},
|
|
72
|
-
{
|
|
73
|
-
build: {
|
|
74
|
-
templates: {
|
|
75
|
-
source: './test/stubs/tailwind'
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
t.true(css.includes('.hidden'))
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
test('uses maizzle template path as content source (single file)', async t => {
|
|
85
|
-
const css = await Tailwind.compile(
|
|
86
|
-
'@tailwind utilities;',
|
|
87
|
-
'<div></div>',
|
|
88
|
-
{},
|
|
89
|
-
{
|
|
90
|
-
build: {
|
|
91
|
-
templates: {
|
|
92
|
-
source: './test/stubs/tailwind/
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
t.true(css.includes('.hidden'))
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
test('uses custom postcss plugins from the maizzle config', async t => {
|
|
102
|
-
const maizzleConfig = {
|
|
103
|
-
env: 'production',
|
|
104
|
-
build: {
|
|
105
|
-
postcss: {
|
|
106
|
-
plugins: [
|
|
107
|
-
require('autoprefixer')({overrideBrowserslist: ['> 0.1%']})
|
|
108
|
-
]
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const css = await Tailwind.compile('.test {transform: scale(0.5)}', '<div class="test">Test</a>', {}, maizzleConfig)
|
|
114
|
-
|
|
115
|
-
t.not(css, undefined)
|
|
116
|
-
t.is(css.trim(), '.inline {display: inline !important} .table {display: table !important} .contents {display: contents !important} .
|
|
117
|
-
})
|
|
1
|
+
const test = require('ava')
|
|
2
|
+
const ora = require('ora')
|
|
3
|
+
const Tailwind = require('../src/generators/tailwindcss')
|
|
4
|
+
|
|
5
|
+
test('throws on compile error', async t => {
|
|
6
|
+
await t.throwsAsync(async () => {
|
|
7
|
+
const spinner = ora('Compiling Tailwind CSS...').start()
|
|
8
|
+
await Tailwind.compile('.test {@apply inexistent;}', '<div class="test">Test</a>', {}, {}, spinner)
|
|
9
|
+
}, {instanceOf: Error, message: 'Tailwind CSS compilation failed'})
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
test('uses defaults if no config specified', async t => {
|
|
13
|
+
const css = await Tailwind.compile(
|
|
14
|
+
'@tailwind utilities;',
|
|
15
|
+
'<p class="xl:z-0"></p>',
|
|
16
|
+
{},
|
|
17
|
+
{env: 'production'}
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
t.not(css, undefined)
|
|
21
|
+
t.true(css.includes('.xl\\:z-0'))
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
test('uses css file provided in environment config', async t => {
|
|
25
|
+
const config = {
|
|
26
|
+
env: 'production',
|
|
27
|
+
build: {
|
|
28
|
+
tailwind: {
|
|
29
|
+
css: './test/stubs/main.css'
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const css = await Tailwind.compile('', '<div class="text-center foo">test</div>', {}, config)
|
|
35
|
+
|
|
36
|
+
t.not(css, undefined)
|
|
37
|
+
t.true(css.includes('.text-center'))
|
|
38
|
+
t.true(css.includes('.foo'))
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
test('works with custom `content` sources', async t => {
|
|
42
|
+
const css = await Tailwind.compile(
|
|
43
|
+
'@tailwind utilities;',
|
|
44
|
+
'<div class="hidden"></div>',
|
|
45
|
+
{
|
|
46
|
+
content: ['./test/stubs/tailwind/*.*']
|
|
47
|
+
}
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
t.true(css.includes('.hidden'))
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
test('works with custom `files` sources', async t => {
|
|
54
|
+
const css = await Tailwind.compile(
|
|
55
|
+
'@tailwind utilities;',
|
|
56
|
+
'<div></div>',
|
|
57
|
+
{
|
|
58
|
+
content: {
|
|
59
|
+
files: ['./test/stubs/tailwind/*.*']
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
t.true(css.includes('.hidden'))
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
test('uses maizzle template path as content source', async t => {
|
|
68
|
+
const css = await Tailwind.compile(
|
|
69
|
+
'@tailwind utilities;',
|
|
70
|
+
'<div></div>',
|
|
71
|
+
{},
|
|
72
|
+
{
|
|
73
|
+
build: {
|
|
74
|
+
templates: {
|
|
75
|
+
source: './test/stubs/tailwind'
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
t.true(css.includes('.hidden'))
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
test('uses maizzle template path as content source (single file)', async t => {
|
|
85
|
+
const css = await Tailwind.compile(
|
|
86
|
+
'@tailwind utilities;',
|
|
87
|
+
'<div></div>',
|
|
88
|
+
{},
|
|
89
|
+
{
|
|
90
|
+
build: {
|
|
91
|
+
templates: {
|
|
92
|
+
source: './test/stubs/tailwind/content-source.html'
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
t.true(css.includes('.hidden'))
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
test('uses custom postcss plugins from the maizzle config', async t => {
|
|
102
|
+
const maizzleConfig = {
|
|
103
|
+
env: 'production',
|
|
104
|
+
build: {
|
|
105
|
+
postcss: {
|
|
106
|
+
plugins: [
|
|
107
|
+
require('autoprefixer')({overrideBrowserslist: ['> 0.1%']})
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const css = await Tailwind.compile('.test {transform: scale(0.5)}', '<div class="test">Test</a>', {}, maizzleConfig)
|
|
114
|
+
|
|
115
|
+
t.not(css, undefined)
|
|
116
|
+
t.is(css.trim(), '.inline {display: inline !important} .table {display: table !important} .contents {display: contents !important} .truncate {overflow: hidden !important;text-overflow: ellipsis !important;white-space: nowrap !important} .uppercase {text-transform: uppercase !important} .lowercase {text-transform: lowercase !important} .capitalize {text-transform: capitalize !important} .test {-webkit-transform: scale(0.5);transform: scale(0.5)}')
|
|
117
|
+
})
|