@@ -19,21 +19,13 @@ test(
19
19
}
20
20
` ,
21
21
'postcss.config.mjs' : js `
22
- /** @type {import('postcss-load-config').Config} */
23
- const config = {
22
+ export default {
24
23
plugins: {
25
24
'@tailwindcss/postcss': {},
26
25
},
27
26
}
28
-
29
- export default config
30
- ` ,
31
- 'next.config.mjs' : js `
32
- /** @type {import('next').NextConfig} */
33
- const nextConfig = {}
34
-
35
- export default nextConfig
36
27
` ,
28
+ 'next.config.mjs' : js `export default {}` ,
37
29
'app/layout.js' : js `
38
30
import './globals.css'
39
31
46
38
}
47
39
` ,
48
40
'app/page.js' : js `
41
+ import styles from './page.module.css'
49
42
export default function Page() {
50
- return <h1 className="text-3xl font-bold underline">Hello, Next.js!</h1>
43
+ return (
44
+ <h1 className={styles.heading + ' text-3xl font-bold underline'}>Hello, Next.js!</h1>
45
+ )
46
+ }
47
+ ` ,
48
+ 'app/page.module.css' : css `
49
+ @reference './globals.css';
50
+ .heading {
51
+ @apply text-red-500 animate-ping;
51
52
}
52
53
` ,
53
54
'app/globals.css' : css `
@@ -60,14 +61,26 @@ test(
60
61
await exec ( 'pnpm next build' )
61
62
62
63
let files = await fs . glob ( '.next/static/css/**/*.css' )
63
- expect ( files ) . toHaveLength ( 1 )
64
- let [ filename ] = files [ 0 ]
64
+ expect ( files ) . toHaveLength ( 2 )
65
65
66
- await fs . expectFileToContain ( filename , [
66
+ let globalCss : string | null = null
67
+ let moduleCss : string | null = null
68
+ for ( let [ filename , content ] of files ) {
69
+ if ( content . includes ( '@keyframes page_ping' ) ) moduleCss = filename
70
+ else globalCss = filename
71
+ }
72
+
73
+ await fs . expectFileToContain ( globalCss ! , [
67
74
candidate `underline` ,
68
75
candidate `font-bold` ,
69
76
candidate `text-3xl` ,
70
77
] )
78
+
79
+ await fs . expectFileToContain ( moduleCss ! , [
80
+ 'color:var(--color-red-500,oklch(.637 .237 25.331)' ,
81
+ 'animation:var(--animate-ping,ping 1s cubic-bezier(0,0,.2,1) infinite)' ,
82
+ / @ k e y f r a m e s p a g e _ p i n g .* { 7 5 % , t o { transform:s c a l e \( 2 \) ; o p a c i t y : 0 } / ,
83
+ ] )
71
84
} ,
72
85
)
73
86
@@ -90,21 +103,13 @@ describe.each(['turbo', 'webpack'])('%s', (bundler) => {
90
103
}
91
104
` ,
92
105
'postcss.config.mjs' : js `
93
- /** @type {import('postcss-load-config').Config} */
94
- const config = {
106
+ export default {
95
107
plugins: {
96
108
'@tailwindcss/postcss': {},
97
109
},
98
110
}
99
-
100
- export default config
101
- ` ,
102
- 'next.config.mjs' : js `
103
- /** @type {import('next').NextConfig} */
104
- const nextConfig = {}
105
-
106
- export default nextConfig
107
111
` ,
112
+ 'next.config.mjs' : js `export default {}` ,
108
113
'app/layout.js' : js `
109
114
import './globals.css'
110
115
@@ -117,8 +122,15 @@ describe.each(['turbo', 'webpack'])('%s', (bundler) => {
117
122
}
118
123
` ,
119
124
'app/page.js' : js `
125
+ import styles from './page.module.css'
120
126
export default function Page() {
121
- return <h1 className="underline">Hello, Next.js!</h1>
127
+ return <h1 className={styles.heading + ' underline'}>Hello, Next.js!</h1>
128
+ }
129
+ ` ,
130
+ 'app/page.module.css' : css `
131
+ @reference './globals.css';
132
+ .heading {
133
+ @apply text-red-500 animate-ping content-['module'];
122
134
}
123
135
` ,
124
136
'app/globals.css' : css `
@@ -142,13 +154,16 @@ describe.each(['turbo', 'webpack'])('%s', (bundler) => {
142
154
await retryAssertion ( async ( ) => {
143
155
let css = await fetchStyles ( url )
144
156
expect ( css ) . toContain ( candidate `underline` )
157
+ expect ( css ) . toContain ( 'content: var(--tw-content)' )
158
+ expect ( css ) . toContain ( '@keyframes' )
145
159
} )
146
160
147
161
await fs . write (
148
162
'app/page.js' ,
149
163
js `
164
+ import styles from './page.module.css'
150
165
export default function Page() {
151
- return <h1 className=" underline text -red-500" >Hello, Next.js!</h1>
166
+ return <h1 className={styles.heading + ' underline bg -red-500'} >Hello, Next.js!</h1>
152
167
}
153
168
` ,
154
169
)
@@ -157,7 +172,9 @@ describe.each(['turbo', 'webpack'])('%s', (bundler) => {
157
172
await retryAssertion ( async ( ) => {
158
173
let css = await fetchStyles ( url )
159
174
expect ( css ) . toContain ( candidate `underline` )
160
- expect ( css ) . toContain ( candidate `text-red-500` )
175
+ expect ( css ) . toContain ( candidate `bg-red-500` )
176
+ expect ( css ) . toContain ( 'content: var(--tw-content)' )
177
+ expect ( css ) . toContain ( '@keyframes' )
161
178
} )
162
179
} ,
163
180
)
@@ -181,21 +198,13 @@ test(
181
198
}
182
199
` ,
183
200
'postcss.config.mjs' : js `
184
- /** @type {import('postcss-load-config').Config} */
185
- const config = {
201
+ export default {
186
202
plugins: {
187
203
'@tailwindcss/postcss': {},
188
204
},
189
205
}
190
-
191
- export default config
192
- ` ,
193
- 'next.config.mjs' : js `
194
- /** @type {import('next').NextConfig} */
195
- const nextConfig = {}
196
-
197
- export default nextConfig
198
206
` ,
207
+ 'next.config.mjs' : js `export default {}` ,
199
208
'app/a/[slug]/page.js' : js `
200
209
export default function Page() {
201
210
return <h1 className="content-['[slug]']">Hello, Next.js!</h1>
0 commit comments