11/**
22 * Docusaurus plugin to fix CSS minification issues with Tailwind CSS v4
3- * This prevents the CSS minifier from breaking Tailwind's output
3+ * Completely disables CSS minification to prevent breaking Tailwind's output
44 */
55function fixCssMinification ( context , options ) {
66 return {
@@ -10,54 +10,18 @@ function fixCssMinification(context, options) {
1010 return { } ;
1111 }
1212
13- // Find and configure CSS minimizer
14- const minimizerPlugins = config . optimization ?. minimizer || [ ] ;
15-
16- minimizerPlugins . forEach ( ( plugin , index ) => {
17- // Check if this is the CSS minimizer plugin
18- // It could be CssMinimizerPlugin or an instance
19- const pluginName = plugin ?. constructor ?. name || '' ;
20- const isCssMinimizer = pluginName === 'CssMinimizerPlugin' ||
21- pluginName . includes ( 'CssMinimizer' ) ||
22- ( plugin . constructor && plugin . constructor . toString ( ) . includes ( 'CssMinimizer' ) ) ;
23-
24- if ( isCssMinimizer ) {
25- // Replace with a safer configuration
26- try {
27- // Try to configure the minimizer to be less aggressive
28- if ( plugin . options ) {
29- plugin . options . minimizerOptions = {
30- preset : [
31- 'default' ,
32- {
33- // Critical: Disable features that break Tailwind CSS v4
34- discardComments : { removeAll : false } ,
35- normalizeWhitespace : false ,
36- reduceIdents : false , // Don't rename keyframes
37- mergeRules : false , // Don't merge rules
38- reduceTransforms : false ,
39- discardUnused : false ,
40- // Only safe minifications
41- minifySelectors : true ,
42- minifyParams : true ,
43- minifyFontValues : true ,
44- minifyGradients : true ,
45- minifyTimingFunctions : true ,
46- } ,
47- ] ,
48- } ;
49- }
50-
51- // Also try to set parallel to false to avoid race conditions
52- if ( plugin . options && typeof plugin . options . parallel !== 'undefined' ) {
53- plugin . options . parallel = false ;
54- }
55- } catch ( e ) {
56- // If configuration fails, try to replace the plugin entirely
57- console . warn ( 'Could not configure CSS minimizer, trying alternative approach' ) ;
58- }
59- }
60- } ) ;
13+ // Remove CSS minimizer entirely to prevent breaking Tailwind CSS v4
14+ if ( config . optimization && config . optimization . minimizer ) {
15+ config . optimization . minimizer = config . optimization . minimizer . filter ( ( plugin ) => {
16+ const pluginName = plugin ?. constructor ?. name || '' ;
17+ const isCssMinimizer = pluginName === 'CssMinimizerPlugin' ||
18+ pluginName . includes ( 'CssMinimizer' ) ||
19+ ( plugin . constructor && plugin . constructor . toString ( ) . includes ( 'CssMinimizer' ) ) ;
20+
21+ // Remove CSS minimizer - we'll let PostCSS handle optimization
22+ return ! isCssMinimizer ;
23+ } ) ;
24+ }
6125
6226 return { } ;
6327 } ,
0 commit comments