-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JIT: Replace
@tailwind screens
with @tailwind variants
- Loading branch information
1 parent
353ffae
commit 2d0ac89
Showing
5 changed files
with
111 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import postcss from 'postcss' | ||
import path from 'path' | ||
import tailwind from '../../src/jit/index.js' | ||
|
||
function run(input, config = {}) { | ||
const { currentTestName } = expect.getState() | ||
|
||
return postcss(tailwind(config)).process(input, { | ||
from: `${path.resolve(__filename)}?test=${currentTestName}`, | ||
}) | ||
} | ||
|
||
test('class variants are inserted at `@tailwind variants`', async () => { | ||
let config = { | ||
mode: 'jit', | ||
purge: [ | ||
{ | ||
raw: `font-bold hover:font-bold md:font-bold`, | ||
}, | ||
], | ||
theme: {}, | ||
plugins: [], | ||
} | ||
|
||
let css = ` | ||
@tailwind utilities; | ||
@tailwind variants; | ||
.foo { | ||
color: black; | ||
} | ||
` | ||
|
||
return run(css, config).then((result) => { | ||
expect(result.css).toMatchFormattedCss(` | ||
.font-bold { | ||
font-weight: 700; | ||
} | ||
.hover\\:font-bold:hover { | ||
font-weight: 700; | ||
} | ||
@media (min-width: 768px) { | ||
.md\\:font-bold { | ||
font-weight: 700; | ||
} | ||
} | ||
.foo { | ||
color: black; | ||
} | ||
`) | ||
}) | ||
}) | ||
|
||
test('`@tailwind screens` works as an alias for `@tailwind variants`', async () => { | ||
let config = { | ||
mode: 'jit', | ||
purge: [ | ||
{ | ||
raw: `font-bold hover:font-bold md:font-bold`, | ||
}, | ||
], | ||
theme: {}, | ||
plugins: [], | ||
} | ||
|
||
let css = ` | ||
@tailwind utilities; | ||
@tailwind screens; | ||
.foo { | ||
color: black; | ||
} | ||
` | ||
|
||
return run(css, config).then((result) => { | ||
expect(result.css).toMatchFormattedCss(` | ||
.font-bold { | ||
font-weight: 700; | ||
} | ||
.hover\\:font-bold:hover { | ||
font-weight: 700; | ||
} | ||
@media (min-width: 768px) { | ||
.md\\:font-bold { | ||
font-weight: 700; | ||
} | ||
} | ||
.foo { | ||
color: black; | ||
} | ||
`) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@tailwind variants; |