@@ -2,7 +2,7 @@ import path from 'node:path'
2
2
import { candidate , css , html , js , json , test , yaml } from '../utils'
3
3
4
4
test (
5
- 'production build' ,
5
+ 'production build (string) ' ,
6
6
{
7
7
fs : {
8
8
'package.json' : json `{}` ,
@@ -69,6 +69,140 @@ test(
69
69
} ,
70
70
)
71
71
72
+ test (
73
+ 'production build (ESM)' ,
74
+ {
75
+ fs : {
76
+ 'package.json' : json `{}` ,
77
+ 'pnpm-workspace.yaml' : yaml `
78
+ #
79
+ packages:
80
+ - project-a
81
+ ` ,
82
+ 'project-a/package.json' : json `
83
+ {
84
+ "dependencies": {
85
+ "postcss": "^8",
86
+ "postcss-cli": "^10",
87
+ "tailwindcss": "workspace:^",
88
+ "@tailwindcss/postcss": "workspace:^"
89
+ }
90
+ }
91
+ ` ,
92
+ 'project-a/postcss.config.mjs' : js `
93
+ import tailwindcss from '@tailwindcss/postcss'
94
+ export default {
95
+ plugins: [tailwindcss()],
96
+ }
97
+ ` ,
98
+ 'project-a/index.html' : html `
99
+ <div
100
+ class="underline 2xl:font-bold hocus:underline inverted:flex"
101
+ ></div>
102
+ ` ,
103
+ 'project-a/plugin.js' : js `
104
+ module.exports = function ({ addVariant }) {
105
+ addVariant('inverted', '@media (inverted-colors: inverted)')
106
+ addVariant('hocus', ['&:focus', '&:hover'])
107
+ }
108
+ ` ,
109
+ 'project-a/src/index.css' : css `
110
+ @import 'tailwindcss/utilities';
111
+ @source '../../project-b/src/**/*.js';
112
+ @plugin '../plugin.js';
113
+ ` ,
114
+ 'project-a/src/index.js' : js `
115
+ const className = "content-['a/src/index.js']"
116
+ module.exports = { className }
117
+ ` ,
118
+ 'project-b/src/index.js' : js `
119
+ const className = "content-['b/src/index.js']"
120
+ module.exports = { className }
121
+ ` ,
122
+ } ,
123
+ } ,
124
+ async ( { root, fs, exec } ) => {
125
+ await exec ( 'pnpm postcss src/index.css --output dist/out.css' , {
126
+ cwd : path . join ( root , 'project-a' ) ,
127
+ } )
128
+
129
+ await fs . expectFileToContain ( 'project-a/dist/out.css' , [
130
+ candidate `underline` ,
131
+ candidate `content-['a/src/index.js']` ,
132
+ candidate `content-['b/src/index.js']` ,
133
+ candidate `inverted:flex` ,
134
+ candidate `hocus:underline` ,
135
+ ] )
136
+ } ,
137
+ )
138
+
139
+ test (
140
+ 'production build (CJS)' ,
141
+ {
142
+ fs : {
143
+ 'package.json' : json `{}` ,
144
+ 'pnpm-workspace.yaml' : yaml `
145
+ #
146
+ packages:
147
+ - project-a
148
+ ` ,
149
+ 'project-a/package.json' : json `
150
+ {
151
+ "dependencies": {
152
+ "postcss": "^8",
153
+ "postcss-cli": "^10",
154
+ "tailwindcss": "workspace:^",
155
+ "@tailwindcss/postcss": "workspace:^"
156
+ }
157
+ }
158
+ ` ,
159
+ 'project-a/postcss.config.cjs' : js `
160
+ let tailwindcss = require('@tailwindcss/postcss')
161
+ module.exports = {
162
+ plugins: [tailwindcss()],
163
+ }
164
+ ` ,
165
+ 'project-a/index.html' : html `
166
+ <div
167
+ class="underline 2xl:font-bold hocus:underline inverted:flex"
168
+ ></div>
169
+ ` ,
170
+ 'project-a/plugin.js' : js `
171
+ module.exports = function ({ addVariant }) {
172
+ addVariant('inverted', '@media (inverted-colors: inverted)')
173
+ addVariant('hocus', ['&:focus', '&:hover'])
174
+ }
175
+ ` ,
176
+ 'project-a/src/index.css' : css `
177
+ @import 'tailwindcss/utilities';
178
+ @source '../../project-b/src/**/*.js';
179
+ @plugin '../plugin.js';
180
+ ` ,
181
+ 'project-a/src/index.js' : js `
182
+ const className = "content-['a/src/index.js']"
183
+ module.exports = { className }
184
+ ` ,
185
+ 'project-b/src/index.js' : js `
186
+ const className = "content-['b/src/index.js']"
187
+ module.exports = { className }
188
+ ` ,
189
+ } ,
190
+ } ,
191
+ async ( { root, fs, exec } ) => {
192
+ await exec ( 'pnpm postcss src/index.css --output dist/out.css' , {
193
+ cwd : path . join ( root , 'project-a' ) ,
194
+ } )
195
+
196
+ await fs . expectFileToContain ( 'project-a/dist/out.css' , [
197
+ candidate `underline` ,
198
+ candidate `content-['a/src/index.js']` ,
199
+ candidate `content-['b/src/index.js']` ,
200
+ candidate `inverted:flex` ,
201
+ candidate `hocus:underline` ,
202
+ ] )
203
+ } ,
204
+ )
205
+
72
206
test (
73
207
'watch mode' ,
74
208
{
0 commit comments