@@ -97,23 +97,30 @@ export default function tailwindcss(opts: PluginOptions = {}): Plugin[] {
9797 name : '@tailwindcss/vite:generate:serve' ,
9898 apply : 'serve' ,
9999 enforce : 'pre' ,
100+ transform : {
101+ filter : {
102+ id : {
103+ exclude : [ / \/ \. v i t e \/ / , SPECIAL_QUERY_RE , COMMON_JS_PROXY_RE ] ,
104+ include : [ / \. c s s (?: \? .* ) ? $ / , / & l a n g \. c s s / , INLINE_STYLE_ID_RE ] ,
105+ } ,
106+ } ,
107+ async handler ( src , id ) {
108+ if ( ! isPotentialCssRootFile ( id ) ) return
100109
101- async transform ( src , id , options ) {
102- if ( ! isPotentialCssRootFile ( id ) ) return
103-
104- using I = new Instrumentation ( )
105- DEBUG && I . start ( '[@tailwindcss/vite] Generate CSS (serve)' )
110+ using I = new Instrumentation ( )
111+ DEBUG && I . start ( '[@tailwindcss/vite] Generate CSS (serve)' )
106112
107- let root = roots . get ( id )
113+ let root = roots . get ( id )
108114
109- let result = await root . generate ( src , ( file ) => this . addWatchFile ( file ) , I )
110- if ( ! result ) {
111- roots . delete ( id )
112- return src
113- }
115+ let result = await root . generate ( src , ( file ) => this . addWatchFile ( file ) , I )
116+ if ( ! result ) {
117+ roots . delete ( id )
118+ return src
119+ }
114120
115- DEBUG && I . end ( '[@tailwindcss/vite] Generate CSS (serve)' )
116- return result
121+ DEBUG && I . end ( '[@tailwindcss/vite] Generate CSS (serve)' )
122+ return result
123+ } ,
117124 } ,
118125 } ,
119126
@@ -123,31 +130,39 @@ export default function tailwindcss(opts: PluginOptions = {}): Plugin[] {
123130 apply : 'build' ,
124131 enforce : 'pre' ,
125132
126- async transform ( src , id ) {
127- if ( ! isPotentialCssRootFile ( id ) ) return
133+ transform : {
134+ filter : {
135+ id : {
136+ exclude : [ / \/ \. v i t e \/ / , SPECIAL_QUERY_RE , COMMON_JS_PROXY_RE ] ,
137+ include : [ / \. c s s (?: \? .* ) ? $ / , / & l a n g \. c s s / , INLINE_STYLE_ID_RE ] ,
138+ } ,
139+ } ,
140+ async handler ( src , id ) {
141+ if ( ! isPotentialCssRootFile ( id ) ) return
128142
129- using I = new Instrumentation ( )
130- DEBUG && I . start ( '[@tailwindcss/vite] Generate CSS (build)' )
143+ using I = new Instrumentation ( )
144+ DEBUG && I . start ( '[@tailwindcss/vite] Generate CSS (build)' )
131145
132- let root = roots . get ( id )
146+ let root = roots . get ( id )
133147
134- let result = await root . generate ( src , ( file ) => this . addWatchFile ( file ) , I )
135- if ( ! result ) {
136- roots . delete ( id )
137- return src
138- }
139- DEBUG && I . end ( '[@tailwindcss/vite] Generate CSS (build)' )
140-
141- if ( shouldOptimize ) {
142- DEBUG && I . start ( '[@tailwindcss/vite] Optimize CSS' )
143- result = optimize ( result . code , {
144- minify,
145- map : result . map ,
146- } )
147- DEBUG && I . end ( '[@tailwindcss/vite] Optimize CSS' )
148- }
148+ let result = await root . generate ( src , ( file ) => this . addWatchFile ( file ) , I )
149+ if ( ! result ) {
150+ roots . delete ( id )
151+ return src
152+ }
153+ DEBUG && I . end ( '[@tailwindcss/vite] Generate CSS (build)' )
154+
155+ if ( shouldOptimize ) {
156+ DEBUG && I . start ( '[@tailwindcss/vite] Optimize CSS' )
157+ result = optimize ( result . code , {
158+ minify,
159+ map : result . map ,
160+ } )
161+ DEBUG && I . end ( '[@tailwindcss/vite] Optimize CSS' )
162+ }
149163
150- return result
164+ return result
165+ } ,
151166 } ,
152167 } ,
153168 ] satisfies Plugin [ ]
0 commit comments