@@ -93,6 +93,84 @@ describe('TailwindcssPatcher', () => {
9393 }
9494 } )
9595
96+ it ( 'merges multiple @config directives in a single CSS entry' , async ( ) => {
97+ const workspaceRoot = await fs . mkdtemp ( path . join ( __dirname , 'tmp-multi-config-' ) )
98+ try {
99+ const cssDir = path . join ( workspaceRoot , 'src' )
100+ await fs . ensureDir ( cssDir )
101+
102+ const configA = path . join ( workspaceRoot , 'tailwind.config.js' )
103+ const configB = path . join ( workspaceRoot , 'tailwind.extra.js' )
104+
105+ await fs . writeFile (
106+ configA ,
107+ [
108+ 'module.exports = {' ,
109+ ' content: ["./src/**/*.{html,css}"],' ,
110+ ' theme: {' ,
111+ ' extend: {' ,
112+ ' colors: { configa: "#111111" },' ,
113+ ' },' ,
114+ ' },' ,
115+ '};' ,
116+ ] . join ( '\n' ) ,
117+ 'utf8' ,
118+ )
119+
120+ await fs . writeFile (
121+ configB ,
122+ [
123+ 'module.exports = {' ,
124+ ' content: ["./src/**/*.{html,css}"],' ,
125+ ' theme: {' ,
126+ ' extend: {' ,
127+ ' colors: { configb: "#222222" },' ,
128+ ' },' ,
129+ ' },' ,
130+ '};' ,
131+ ] . join ( '\n' ) ,
132+ 'utf8' ,
133+ )
134+
135+ const cssEntry = path . join ( cssDir , 'app.css' )
136+ await fs . writeFile (
137+ cssEntry ,
138+ [
139+ '@import "tailwindcss";' ,
140+ '@config "../tailwind.config.js";' ,
141+ '@config "../tailwind.extra.js";' ,
142+ ] . join ( '\n' ) ,
143+ 'utf8' ,
144+ )
145+
146+ const usageFile = path . join ( cssDir , 'index.html' )
147+ await fs . writeFile ( usageFile , '<div class="bg-configa bg-configb"></div>' , 'utf8' )
148+
149+ const patcher = new TailwindcssPatcher ( {
150+ cwd : workspaceRoot ,
151+ overwrite : false ,
152+ cache : false ,
153+ output : {
154+ enabled : false ,
155+ } ,
156+ tailwind : {
157+ version : 4 ,
158+ v4 : {
159+ base : workspaceRoot ,
160+ cssEntries : [ cssEntry ] ,
161+ } ,
162+ } ,
163+ } )
164+
165+ const result = await patcher . extract ( { write : false } )
166+ expect ( result . classSet ?. has ( 'bg-configa' ) ) . toBe ( true )
167+ expect ( result . classSet ?. has ( 'bg-configb' ) ) . toBe ( true )
168+ }
169+ finally {
170+ await fs . remove ( workspaceRoot )
171+ }
172+ } )
173+
96174 it ( 'falls back to workspace sources when cssEntries directory is empty' , async ( ) => {
97175 const workspaceRoot = await fs . mkdtemp ( path . join ( __dirname , 'tmp-workspace-' ) )
98176 try {
0 commit comments