2023-01-20 12:45:04 -05:00
|
|
|
import { crosscheck, run, html, css, defaults } from './util/run'
|
|
|
|
|
|
|
|
|
|
crosscheck(() => {
|
|
|
|
|
test('custom user-land utilities', () => {
|
|
|
|
|
let config = {
|
|
|
|
|
content: [
|
|
|
|
|
{
|
|
|
|
|
raw: html`<div
|
|
|
|
|
class="focus:hover:align-chocolate align-banana hover:align-banana uppercase"
|
|
|
|
|
></div>`,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
corePlugins: { preflight: false },
|
|
|
|
|
theme: {},
|
|
|
|
|
plugins: [],
|
Remove AOT (#5340)
* make `jit` mode the default when no mode is specified
* unify JIT and AOT codepaths
* ensure `Object.entries` on undefined doesn't break
It could be that sometimes you don't have values in your config (e.g.: `presets: []`), this in turn will break some plugins where we assume we have a value.
* drop AOT specific tests
These tests are all covered by JIT mode already and were AOT specific.
* simplify tests, and add a few
Some of the tests were written for AOT specifically, some were missing. We also updated the way we write those tests, essentially making Tailwind a blackbox, by testing against the final output.
Now that JIT mode is the default, this is super fast because we only generate what is used, instead of partially testing in a 3MB file or building it all, then purging.
* add some todo's to make sure we warn in a few cases
* make `darkMode: 'media'`, the default
This also includes moving dark mode tests to its own dedicated file.
* remove PostCSS 7 compat mode
* update CLI to be JIT-first
* fix integration tests
This is not a _real_ fix, but it does solve the broken test for now.
* warn when using @responsive or @variants
* remove the JIT preview warning
* remove AOT-only code paths
* remove all `mode: 'jit'` blocks
Also remove `variants: {}` since they are not useful in `JIT` mode
anymore.
* drop unused dependencies
* rename `purge` to `content`
* remove static CDN builds
* mark `--purge` as deprecated in the CLI
This will still work, but a warning will be printed and it won't show up
in the `--help` output.
* cleanup nesting plugin
We don't have to duplicate it anymore since there is no PostCSS 7
version anymore.
* make sure integration tests run in band
* cleanup folder structure
* make sure nesting folder is available
* simplify resolving of purge/content information
2021-09-01 17:13:59 +02:00
|
|
|
}
|
|
|
|
|
|
2023-01-20 12:45:04 -05:00
|
|
|
let input = css`
|
|
|
|
|
@layer utilities {
|
|
|
|
|
.align-banana {
|
|
|
|
|
text-align: banana;
|
|
|
|
|
}
|
Remove AOT (#5340)
* make `jit` mode the default when no mode is specified
* unify JIT and AOT codepaths
* ensure `Object.entries` on undefined doesn't break
It could be that sometimes you don't have values in your config (e.g.: `presets: []`), this in turn will break some plugins where we assume we have a value.
* drop AOT specific tests
These tests are all covered by JIT mode already and were AOT specific.
* simplify tests, and add a few
Some of the tests were written for AOT specifically, some were missing. We also updated the way we write those tests, essentially making Tailwind a blackbox, by testing against the final output.
Now that JIT mode is the default, this is super fast because we only generate what is used, instead of partially testing in a 3MB file or building it all, then purging.
* add some todo's to make sure we warn in a few cases
* make `darkMode: 'media'`, the default
This also includes moving dark mode tests to its own dedicated file.
* remove PostCSS 7 compat mode
* update CLI to be JIT-first
* fix integration tests
This is not a _real_ fix, but it does solve the broken test for now.
* warn when using @responsive or @variants
* remove the JIT preview warning
* remove AOT-only code paths
* remove all `mode: 'jit'` blocks
Also remove `variants: {}` since they are not useful in `JIT` mode
anymore.
* drop unused dependencies
* rename `purge` to `content`
* remove static CDN builds
* mark `--purge` as deprecated in the CLI
This will still work, but a warning will be printed and it won't show up
in the `--help` output.
* cleanup nesting plugin
We don't have to duplicate it anymore since there is no PostCSS 7
version anymore.
* make sure integration tests run in band
* cleanup folder structure
* make sure nesting folder is available
* simplify resolving of purge/content information
2021-09-01 17:13:59 +02:00
|
|
|
}
|
|
|
|
|
|
2023-01-20 12:45:04 -05:00
|
|
|
@tailwind base;
|
|
|
|
|
@tailwind components;
|
|
|
|
|
@tailwind utilities;
|
2022-01-07 11:39:45 -05:00
|
|
|
|
2023-01-20 12:45:04 -05:00
|
|
|
@layer utilities {
|
|
|
|
|
.align-chocolate {
|
|
|
|
|
text-align: chocolate;
|
|
|
|
|
}
|
Remove AOT (#5340)
* make `jit` mode the default when no mode is specified
* unify JIT and AOT codepaths
* ensure `Object.entries` on undefined doesn't break
It could be that sometimes you don't have values in your config (e.g.: `presets: []`), this in turn will break some plugins where we assume we have a value.
* drop AOT specific tests
These tests are all covered by JIT mode already and were AOT specific.
* simplify tests, and add a few
Some of the tests were written for AOT specifically, some were missing. We also updated the way we write those tests, essentially making Tailwind a blackbox, by testing against the final output.
Now that JIT mode is the default, this is super fast because we only generate what is used, instead of partially testing in a 3MB file or building it all, then purging.
* add some todo's to make sure we warn in a few cases
* make `darkMode: 'media'`, the default
This also includes moving dark mode tests to its own dedicated file.
* remove PostCSS 7 compat mode
* update CLI to be JIT-first
* fix integration tests
This is not a _real_ fix, but it does solve the broken test for now.
* warn when using @responsive or @variants
* remove the JIT preview warning
* remove AOT-only code paths
* remove all `mode: 'jit'` blocks
Also remove `variants: {}` since they are not useful in `JIT` mode
anymore.
* drop unused dependencies
* rename `purge` to `content`
* remove static CDN builds
* mark `--purge` as deprecated in the CLI
This will still work, but a warning will be printed and it won't show up
in the `--help` output.
* cleanup nesting plugin
We don't have to duplicate it anymore since there is no PostCSS 7
version anymore.
* make sure integration tests run in band
* cleanup folder structure
* make sure nesting folder is available
* simplify resolving of purge/content information
2021-09-01 17:13:59 +02:00
|
|
|
}
|
2023-01-20 12:45:04 -05:00
|
|
|
`
|
|
|
|
|
|
|
|
|
|
return run(input, config).then((result) => {
|
|
|
|
|
expect(result.css).toMatchFormattedCss(css`
|
|
|
|
|
${defaults}
|
|
|
|
|
.uppercase {
|
|
|
|
|
text-transform: uppercase;
|
|
|
|
|
}
|
2023-01-31 15:37:49 +01:00
|
|
|
.align-banana,
|
2023-01-20 12:45:04 -05:00
|
|
|
.hover\:align-banana:hover {
|
|
|
|
|
text-align: banana;
|
|
|
|
|
}
|
|
|
|
|
.focus\:hover\:align-chocolate:hover:focus {
|
|
|
|
|
text-align: chocolate;
|
|
|
|
|
}
|
|
|
|
|
`)
|
|
|
|
|
})
|
Remove AOT (#5340)
* make `jit` mode the default when no mode is specified
* unify JIT and AOT codepaths
* ensure `Object.entries` on undefined doesn't break
It could be that sometimes you don't have values in your config (e.g.: `presets: []`), this in turn will break some plugins where we assume we have a value.
* drop AOT specific tests
These tests are all covered by JIT mode already and were AOT specific.
* simplify tests, and add a few
Some of the tests were written for AOT specifically, some were missing. We also updated the way we write those tests, essentially making Tailwind a blackbox, by testing against the final output.
Now that JIT mode is the default, this is super fast because we only generate what is used, instead of partially testing in a 3MB file or building it all, then purging.
* add some todo's to make sure we warn in a few cases
* make `darkMode: 'media'`, the default
This also includes moving dark mode tests to its own dedicated file.
* remove PostCSS 7 compat mode
* update CLI to be JIT-first
* fix integration tests
This is not a _real_ fix, but it does solve the broken test for now.
* warn when using @responsive or @variants
* remove the JIT preview warning
* remove AOT-only code paths
* remove all `mode: 'jit'` blocks
Also remove `variants: {}` since they are not useful in `JIT` mode
anymore.
* drop unused dependencies
* rename `purge` to `content`
* remove static CDN builds
* mark `--purge` as deprecated in the CLI
This will still work, but a warning will be printed and it won't show up
in the `--help` output.
* cleanup nesting plugin
We don't have to duplicate it anymore since there is no PostCSS 7
version anymore.
* make sure integration tests run in band
* cleanup folder structure
* make sure nesting folder is available
* simplify resolving of purge/content information
2021-09-01 17:13:59 +02:00
|
|
|
})
|
2021-09-03 17:46:15 +02:00
|
|
|
|
2023-01-20 12:45:04 -05:00
|
|
|
test('comments can be used inside layers without crashing', () => {
|
|
|
|
|
let config = {
|
|
|
|
|
content: [
|
|
|
|
|
{
|
|
|
|
|
raw: html`<div class="important-utility important-component"></div>`,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
corePlugins: { preflight: false },
|
|
|
|
|
theme: {},
|
|
|
|
|
plugins: [],
|
2021-10-22 15:19:21 +02:00
|
|
|
}
|
|
|
|
|
|
2023-01-20 12:45:04 -05:00
|
|
|
let input = css`
|
|
|
|
|
@tailwind base;
|
|
|
|
|
@tailwind components;
|
|
|
|
|
@tailwind utilities;
|
|
|
|
|
|
|
|
|
|
@layer base {
|
|
|
|
|
/* Important base */
|
|
|
|
|
div {
|
|
|
|
|
background-color: #bada55;
|
|
|
|
|
}
|
2021-10-22 15:19:21 +02:00
|
|
|
}
|
|
|
|
|
|
2023-01-20 12:45:04 -05:00
|
|
|
@layer utilities {
|
|
|
|
|
/* Important utility */
|
|
|
|
|
.important-utility {
|
|
|
|
|
text-align: banana;
|
|
|
|
|
}
|
2021-10-22 15:19:21 +02:00
|
|
|
}
|
|
|
|
|
|
2023-01-20 12:45:04 -05:00
|
|
|
@layer components {
|
|
|
|
|
/* Important component */
|
|
|
|
|
.important-component {
|
|
|
|
|
text-align: banana;
|
|
|
|
|
}
|
2021-10-22 15:19:21 +02:00
|
|
|
}
|
2023-01-20 12:45:04 -05:00
|
|
|
`
|
|
|
|
|
|
|
|
|
|
return run(input, config).then((result) => {
|
|
|
|
|
expect(result.css).toMatchFormattedCss(css`
|
|
|
|
|
div {
|
|
|
|
|
background-color: #bada55;
|
|
|
|
|
}
|
|
|
|
|
${defaults}
|
2023-01-31 15:37:49 +01:00
|
|
|
.important-component,
|
2023-01-20 12:45:04 -05:00
|
|
|
.important-utility {
|
|
|
|
|
text-align: banana;
|
|
|
|
|
}
|
|
|
|
|
`)
|
|
|
|
|
})
|
2021-10-22 15:19:21 +02:00
|
|
|
})
|
|
|
|
|
|
2023-01-20 12:45:04 -05:00
|
|
|
test('comments can be used inside layers (with important) without crashing', () => {
|
|
|
|
|
let config = {
|
|
|
|
|
important: true,
|
|
|
|
|
content: [
|
|
|
|
|
{
|
|
|
|
|
raw: html`<div class="important-utility important-component"></div>`,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
corePlugins: { preflight: false },
|
|
|
|
|
theme: {},
|
|
|
|
|
plugins: [],
|
2021-10-22 15:19:21 +02:00
|
|
|
}
|
|
|
|
|
|
2023-01-20 12:45:04 -05:00
|
|
|
let input = css`
|
|
|
|
|
@tailwind base;
|
|
|
|
|
@tailwind components;
|
|
|
|
|
@tailwind utilities;
|
|
|
|
|
|
|
|
|
|
@layer base {
|
|
|
|
|
/* Important base */
|
|
|
|
|
div {
|
|
|
|
|
background-color: #bada55;
|
|
|
|
|
}
|
2021-10-22 15:19:21 +02:00
|
|
|
}
|
|
|
|
|
|
2023-01-20 12:45:04 -05:00
|
|
|
@layer utilities {
|
|
|
|
|
/* Important utility */
|
|
|
|
|
.important-utility {
|
|
|
|
|
text-align: banana;
|
|
|
|
|
}
|
2021-10-22 15:19:21 +02:00
|
|
|
}
|
|
|
|
|
|
2023-01-20 12:45:04 -05:00
|
|
|
@layer components {
|
|
|
|
|
/* Important component */
|
|
|
|
|
.important-component {
|
|
|
|
|
text-align: banana;
|
|
|
|
|
}
|
2021-10-22 15:19:21 +02:00
|
|
|
}
|
2023-01-20 12:45:04 -05:00
|
|
|
`
|
|
|
|
|
|
|
|
|
|
return run(input, config).then((result) => {
|
|
|
|
|
expect(result.css).toMatchFormattedCss(css`
|
|
|
|
|
div {
|
|
|
|
|
background-color: #bada55;
|
|
|
|
|
}
|
|
|
|
|
${defaults}
|
2023-01-31 15:37:49 +01:00
|
|
|
.important-component {
|
2023-01-20 12:45:04 -05:00
|
|
|
text-align: banana;
|
|
|
|
|
}
|
|
|
|
|
.important-utility {
|
|
|
|
|
text-align: banana !important;
|
|
|
|
|
}
|
|
|
|
|
`)
|
|
|
|
|
})
|
2021-10-22 15:19:21 +02:00
|
|
|
})
|
|
|
|
|
|
2023-01-20 12:45:04 -05:00
|
|
|
test('layers are grouped and inserted at the matching @tailwind rule', () => {
|
|
|
|
|
let config = {
|
|
|
|
|
content: [
|
|
|
|
|
{
|
|
|
|
|
raw: html`<div class="input btn card float-squirrel align-banana align-sandwich"></div>`,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
plugins: [
|
|
|
|
|
function ({ addBase, addComponents, addUtilities }) {
|
|
|
|
|
addBase({ body: { margin: 0 } })
|
|
|
|
|
|
|
|
|
|
addComponents({
|
|
|
|
|
'.input': { background: 'white' },
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.float-squirrel': { float: 'squirrel' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
corePlugins: { preflight: false },
|
2021-09-03 17:46:15 +02:00
|
|
|
}
|
|
|
|
|
|
2023-01-20 12:45:04 -05:00
|
|
|
let input = css`
|
|
|
|
|
@layer vanilla {
|
|
|
|
|
strong {
|
|
|
|
|
font-weight: medium;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@tailwind base;
|
|
|
|
|
@tailwind components;
|
|
|
|
|
@tailwind utilities;
|
2021-09-03 17:46:15 +02:00
|
|
|
|
2023-01-20 12:45:04 -05:00
|
|
|
@layer components {
|
|
|
|
|
.btn {
|
|
|
|
|
background: blue;
|
|
|
|
|
}
|
2021-09-03 17:46:15 +02:00
|
|
|
}
|
|
|
|
|
|
2023-01-20 12:45:04 -05:00
|
|
|
@layer utilities {
|
|
|
|
|
.align-banana {
|
|
|
|
|
text-align: banana;
|
|
|
|
|
}
|
2021-09-03 17:46:15 +02:00
|
|
|
}
|
|
|
|
|
|
2023-01-20 12:45:04 -05:00
|
|
|
@layer base {
|
|
|
|
|
h1 {
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
}
|
2021-09-03 17:46:15 +02:00
|
|
|
}
|
|
|
|
|
|
2023-01-20 12:45:04 -05:00
|
|
|
@layer components {
|
|
|
|
|
.card {
|
|
|
|
|
border-radius: 12px;
|
|
|
|
|
}
|
2021-09-03 17:46:15 +02:00
|
|
|
}
|
|
|
|
|
|
2023-01-20 12:45:04 -05:00
|
|
|
@layer base {
|
|
|
|
|
p {
|
|
|
|
|
font-weight: normal;
|
|
|
|
|
}
|
2021-09-03 17:46:15 +02:00
|
|
|
}
|
|
|
|
|
|
2023-01-20 12:45:04 -05:00
|
|
|
@layer utilities {
|
|
|
|
|
.align-sandwich {
|
|
|
|
|
text-align: sandwich;
|
|
|
|
|
}
|
2021-09-03 17:46:15 +02:00
|
|
|
}
|
|
|
|
|
|
2023-01-20 12:45:04 -05:00
|
|
|
@layer chocolate {
|
|
|
|
|
a {
|
|
|
|
|
text-decoration: underline;
|
|
|
|
|
}
|
2021-09-03 17:46:15 +02:00
|
|
|
}
|
2023-01-20 12:45:04 -05:00
|
|
|
`
|
2021-09-03 17:46:15 +02:00
|
|
|
|
2023-01-20 12:45:04 -05:00
|
|
|
expect.assertions(2)
|
2021-09-03 17:46:15 +02:00
|
|
|
|
2023-01-20 12:45:04 -05:00
|
|
|
return run(input, config).then((result) => {
|
|
|
|
|
expect(result.warnings().length).toBe(0)
|
|
|
|
|
expect(result.css).toMatchFormattedCss(css`
|
|
|
|
|
@layer vanilla {
|
|
|
|
|
strong {
|
|
|
|
|
font-weight: medium;
|
|
|
|
|
}
|
2021-09-03 17:46:15 +02:00
|
|
|
}
|
2023-01-20 12:45:04 -05:00
|
|
|
body {
|
|
|
|
|
margin: 0;
|
|
|
|
|
}
|
|
|
|
|
h1 {
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
}
|
|
|
|
|
p {
|
|
|
|
|
font-weight: normal;
|
|
|
|
|
}
|
|
|
|
|
${defaults}
|
|
|
|
|
.input {
|
2023-01-31 15:37:49 +01:00
|
|
|
background: #fff;
|
2023-01-20 12:45:04 -05:00
|
|
|
}
|
|
|
|
|
.btn {
|
2023-01-31 15:37:49 +01:00
|
|
|
background: #00f;
|
2023-01-20 12:45:04 -05:00
|
|
|
}
|
|
|
|
|
.card {
|
|
|
|
|
border-radius: 12px;
|
|
|
|
|
}
|
|
|
|
|
.float-squirrel {
|
|
|
|
|
float: squirrel;
|
|
|
|
|
}
|
|
|
|
|
.align-banana {
|
|
|
|
|
text-align: banana;
|
|
|
|
|
}
|
|
|
|
|
.align-sandwich {
|
|
|
|
|
text-align: sandwich;
|
|
|
|
|
}
|
|
|
|
|
@layer chocolate {
|
|
|
|
|
a {
|
|
|
|
|
text-decoration: underline;
|
|
|
|
|
}
|
2021-09-03 17:46:15 +02:00
|
|
|
}
|
2023-01-20 12:45:04 -05:00
|
|
|
`)
|
|
|
|
|
})
|
2021-09-03 17:46:15 +02:00
|
|
|
})
|
2021-11-05 15:12:35 +01:00
|
|
|
|
2023-01-20 12:45:04 -05:00
|
|
|
it('should keep `@supports` rules inside `@layer`s', () => {
|
|
|
|
|
let config = {
|
|
|
|
|
content: [{ raw: html`<div class="test"></div>` }],
|
|
|
|
|
plugins: [],
|
|
|
|
|
}
|
2021-11-05 15:12:35 +01:00
|
|
|
|
2023-01-20 12:45:04 -05:00
|
|
|
let input = css`
|
|
|
|
|
@tailwind utilities;
|
2021-11-05 15:12:35 +01:00
|
|
|
|
2023-01-20 12:45:04 -05:00
|
|
|
@layer utilities {
|
2021-11-05 15:12:35 +01:00
|
|
|
.test {
|
2023-01-20 12:45:04 -05:00
|
|
|
--tw-test: 1;
|
2021-11-05 15:12:35 +01:00
|
|
|
}
|
|
|
|
|
|
2023-01-20 12:45:04 -05:00
|
|
|
@supports (backdrop-filter: blur(1px)) {
|
|
|
|
|
.test {
|
|
|
|
|
--tw-test: 0.9;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-11-05 15:12:35 +01:00
|
|
|
}
|
2023-01-20 12:45:04 -05:00
|
|
|
`
|
2021-11-05 15:12:35 +01:00
|
|
|
|
2023-01-20 12:45:04 -05:00
|
|
|
return run(input, config).then((result) => {
|
|
|
|
|
return expect(result.css).toMatchFormattedCss(css`
|
2021-11-05 15:12:35 +01:00
|
|
|
.test {
|
2023-01-20 12:45:04 -05:00
|
|
|
--tw-test: 1;
|
2021-11-05 15:12:35 +01:00
|
|
|
}
|
2023-01-20 12:45:04 -05:00
|
|
|
@supports (backdrop-filter: blur(1px)) {
|
|
|
|
|
.test {
|
|
|
|
|
--tw-test: 0.9;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`)
|
|
|
|
|
})
|
2021-11-05 15:12:35 +01:00
|
|
|
})
|
|
|
|
|
})
|