-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
Copy pathcore-as-postcss-plugin.test.ts
58 lines (56 loc) · 1.49 KB
/
core-as-postcss-plugin.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { describe } from 'vitest'
import { css, js, json, test } from '../utils'
const variantConfig = {
string: {
'postcss.config.js': js`
module.exports = {
plugins: {
tailwindcss: {},
},
}
`,
},
ESM: {
'postcss.config.mjs': js`
import tailwindcss from 'tailwindcss'
export default {
plugins: [tailwindcss()],
}
`,
},
CJS: {
'postcss.config.cjs': js`
let tailwindcss = require('tailwindcss')
module.exports = {
plugins: [tailwindcss()],
}
`,
},
}
describe.each(Object.keys(variantConfig))('%s', (variant) => {
test(
`can not use \`tailwindcss\` as a postcss module`,
{
fs: {
...variantConfig[variant],
'package.json': json`
{
"dependencies": {
"postcss": "^8",
"postcss-cli": "^10",
"tailwindcss": "workspace:^"
}
}
`,
'src/index.css': css`@import 'tailwindcss';`,
},
},
async ({ exec, expect }) => {
expect(
exec('pnpm postcss src/index.css --output dist/out.css', undefined, { ignoreStdErr: true }),
).rejects.toThrowError(
`It looks like you're trying to use \`tailwindcss\` directly as a PostCSS plugin. The PostCSS plugin has moved to a separate package, so to continue using Tailwind CSS with PostCSS you'll need to install \`@tailwindcss/postcss\` and update your PostCSS configuration.`,
)
},
)
})