diff --git a/scripts/post-build.js b/scripts/post-build.js index c0f5f04..2723184 100644 --- a/scripts/post-build.js +++ b/scripts/post-build.js @@ -1,5 +1,5 @@ #!/usr/bin/env node -// Post-build class minifier - updates BOTH HTML classes AND CSS +// Post-build class minifier - updates BOTH HTML classes AND inline CSS const fs = require('fs'); const path = require('path'); @@ -15,8 +15,6 @@ function shouldSkip(c) { if (c.includes('border')) return true; // Widths if (c.startsWith('max-w-')) return true; - // Responsive (sm:, md:, lg:, etc.) - complex to handle properly - if (c.includes(':') && !c.startsWith('dark:')) return true; return false; } @@ -40,7 +38,17 @@ function processFile(filePath) { classMap[darkVer] = classMap[orig]; }); - // Second pass: replace in HTML (including dark: variants) + // Also create responsive mappings (sm:, md:, lg: → same cXX as base) + ['sm:', 'md:', 'lg:', 'xl:', '2xl:'].forEach(prefix => { + Object.keys(classMap).forEach(orig => { + if (!orig.includes(':') && classMap[orig]) { + const respVer = prefix + orig; + classMap[respVer] = classMap[orig]; + } + }); + }); + + // Second pass: replace in HTML matches.forEach(m => { const arr = m.slice(7, -1).split(' ').filter(c => c); const newArr = arr.map(c => shouldSkip(c) ? c : classMap[c]); @@ -50,34 +58,38 @@ function processFile(filePath) { } }); - // Third pass: replace in ALL CSS blocks - const styleMatches = html.match(/