@@ -19,21 +19,13 @@ test(
1919 }
2020 ` ,
2121 'postcss.config.mjs' : js `
22- /** @type {import('postcss-load-config').Config} */
23- const config = {
22+ export default {
2423 plugins: {
2524 '@tailwindcss/postcss': {},
2625 },
2726 }
28-
29- export default config
30- ` ,
31- 'next.config.mjs' : js `
32- /** @type {import('next').NextConfig} */
33- const nextConfig = {}
34-
35- export default nextConfig
3627 ` ,
28+ 'next.config.mjs' : js `export default {}` ,
3729 'app/layout.js' : js `
3830 import './globals.css'
3931
4638 }
4739 ` ,
4840 'app/page.js' : js `
41+ import styles from './page.module.css'
4942 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;
5152 }
5253 ` ,
5354 'app/globals.css' : css `
@@ -60,14 +61,26 @@ test(
6061 await exec ( 'pnpm next build' )
6162
6263 let files = await fs . glob ( '.next/static/css/**/*.css' )
63- expect ( files ) . toHaveLength ( 1 )
64- let [ filename ] = files [ 0 ]
64+ expect ( files ) . toHaveLength ( 2 )
6565
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 ! , [
6774 candidate `underline` ,
6875 candidate `font-bold` ,
6976 candidate `text-3xl` ,
7077 ] )
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+ ] )
7184 } ,
7285)
7386
@@ -90,21 +103,13 @@ describe.each(['turbo', 'webpack'])('%s', (bundler) => {
90103 }
91104 ` ,
92105 'postcss.config.mjs' : js `
93- /** @type {import('postcss-load-config').Config} */
94- const config = {
106+ export default {
95107 plugins: {
96108 '@tailwindcss/postcss': {},
97109 },
98110 }
99-
100- export default config
101- ` ,
102- 'next.config.mjs' : js `
103- /** @type {import('next').NextConfig} */
104- const nextConfig = {}
105-
106- export default nextConfig
107111 ` ,
112+ 'next.config.mjs' : js `export default {}` ,
108113 'app/layout.js' : js `
109114 import './globals.css'
110115
@@ -117,8 +122,15 @@ describe.each(['turbo', 'webpack'])('%s', (bundler) => {
117122 }
118123 ` ,
119124 'app/page.js' : js `
125+ import styles from './page.module.css'
120126 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'];
122134 }
123135 ` ,
124136 'app/globals.css' : css `
@@ -142,13 +154,16 @@ describe.each(['turbo', 'webpack'])('%s', (bundler) => {
142154 await retryAssertion ( async ( ) => {
143155 let css = await fetchStyles ( url )
144156 expect ( css ) . toContain ( candidate `underline` )
157+ expect ( css ) . toContain ( 'content: var(--tw-content)' )
158+ expect ( css ) . toContain ( '@keyframes' )
145159 } )
146160
147161 await fs . write (
148162 'app/page.js' ,
149163 js `
164+ import styles from './page.module.css'
150165 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>
152167 }
153168 ` ,
154169 )
@@ -157,7 +172,9 @@ describe.each(['turbo', 'webpack'])('%s', (bundler) => {
157172 await retryAssertion ( async ( ) => {
158173 let css = await fetchStyles ( url )
159174 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' )
161178 } )
162179 } ,
163180 )
@@ -181,21 +198,13 @@ test(
181198 }
182199 ` ,
183200 'postcss.config.mjs' : js `
184- /** @type {import('postcss-load-config').Config} */
185- const config = {
201+ export default {
186202 plugins: {
187203 '@tailwindcss/postcss': {},
188204 },
189205 }
190-
191- export default config
192- ` ,
193- 'next.config.mjs' : js `
194- /** @type {import('next').NextConfig} */
195- const nextConfig = {}
196-
197- export default nextConfig
198206 ` ,
207+ 'next.config.mjs' : js `export default {}` ,
199208 'app/a/[slug]/page.js' : js `
200209 export default function Page() {
201210 return <h1 className="content-['[slug]']">Hello, Next.js!</h1>
0 commit comments