@@ -141,23 +141,30 @@ function style({
141141 onLoad ( { filter : / .* / , namespace : 'style-content' } , async ( args ) => {
142142 // Process with PostCSS/Tailwind if enabled and file exists
143143 if ( enableTailwind && args . path . includes ( 'tailwind.css' ) && fs . existsSync ( args . path ) ) {
144- const cssContent = await fs . readFile ( args . path , 'utf8' ) ;
145- const result = await postcss ( [ tailwindcss , autoprefixer ] ) . process ( cssContent , {
146- from : args . path ,
147- to : args . path
148- } ) ;
144+ try {
145+ const cssContent = await fs . readFile ( args . path , 'utf8' ) ;
146+ const result = await postcss ( [ tailwindcss , autoprefixer ] ) . process ( cssContent , {
147+ from : args . path ,
148+ to : args . path
149+ } ) ;
149150
150- const options = { ...opt , stdin : { contents : result . css , loader : 'css' } } ;
151- options . loader = options . loader || { } ;
152- // Add the same loaders we add for other places
153- Object . keys ( loader ) . forEach ( ( key ) => {
154- if ( options . loader && ! options . loader [ key ] ) {
155- options . loader [ key ] = loader [ key ] ;
156- }
157- } ) ;
158- const { errors, warnings, outputFiles } = await esbuild . build ( options ) ;
159- return { errors, warnings, contents : outputFiles ! [ 0 ] . text , loader : 'text' } ;
151+ const options = { ...opt , stdin : { contents : result . css , loader : 'css' } } ;
152+ options . loader = options . loader || { } ;
153+ // Add the same loaders we add for other places
154+ Object . keys ( loader ) . forEach ( ( key ) => {
155+ if ( options . loader && ! options . loader [ key ] ) {
156+ options . loader [ key ] = loader [ key ] ;
157+ }
158+ } ) ;
159+ const { errors, warnings, outputFiles } = await esbuild . build ( options ) ;
160+ return { errors, warnings, contents : outputFiles ! [ 0 ] . text , loader : 'text' } ;
161+ } catch ( error ) {
162+ console . error ( `PostCSS processing failed for ${ args . path } :` , error ) ;
163+ throw error ;
164+ }
160165 }
166+ // …rest of the onLoad handler…
167+ } ) ;
161168
162169 // Default behavior for other CSS files
163170 const options = { entryPoints : [ args . path ] , ...opt } ;
0 commit comments