forked from tailwindlabs/tailwindcss
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.test.ts
More file actions
110 lines (104 loc) · 2.88 KB
/
index.test.ts
File metadata and controls
110 lines (104 loc) · 2.88 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import { css, html, js, json, test } from '../utils'
test(
'webpack + PostCSS (watch)',
{
fs: {
'package.json': json`
{
"main": "./src/index.js",
"browser": "./src/index.js",
"dependencies": {
"css-loader": "^6",
"postcss": "^8",
"postcss-loader": "^7",
"webpack": "^5",
"webpack-cli": "^5",
"mini-css-extract-plugin": "^2",
"tailwindcss": "workspace:^",
"@tailwindcss/postcss": "workspace:^"
}
}
`,
'postcss.config.js': js`
/** @type {import('postcss-load-config').Config} */
module.exports = {
plugins: {
'@tailwindcss/postcss': {},
},
}
`,
'webpack.config.js': js`
let MiniCssExtractPlugin = require('mini-css-extract-plugin')
module.exports = {
output: {
clean: true,
},
plugins: [new MiniCssExtractPlugin()],
module: {
rules: [
{
test: /.css$/i,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader'],
},
],
},
}
`,
'src/index.js': js`import './index.css'`,
'src/index.html': html`
<div class="flex"></div>
`,
'src/index.css': css`
@import 'tailwindcss/theme';
@import 'tailwindcss/utilities';
`,
'src/unrelated.module.css': css`
.module {
color: var(--color-blue-500);
}
`,
},
},
async ({ fs, spawn, exec, expect }) => {
// Generate the initial build so output CSS files exist on disk
await exec('pnpm webpack --mode=development')
// NOTE: We are writing to an output CSS file which is not being ignored by
// `.gitignore` nor marked with `@source not`. This should not result in an
// infinite loop.
let process = await spawn('pnpm webpack --mode=development --watch')
await process.onStdout((m) => m.includes('compiled successfully in'))
expect(await fs.dumpFiles('./dist/*.css')).toMatchInlineSnapshot(`
"
--- ./dist/main.css ---
:root, :host {
--color-blue-500: oklch(62.3% 0.214 259.815);
}
.flex {
display: flex;
}
"
`)
await fs.write(
'src/unrelated.module.css',
css`
.module {
color: var(--color-blue-500);
background-color: var(--color-red-500);
}
`,
)
await process.onStdout((m) => m.includes('compiled successfully in'))
expect(await fs.dumpFiles('./dist/*.css')).toMatchInlineSnapshot(`
"
--- ./dist/main.css ---
:root, :host {
--color-red-500: oklch(63.7% 0.237 25.331);
--color-blue-500: oklch(62.3% 0.214 259.815);
}
.flex {
display: flex;
}
"
`)
},
)