-
-
Save adhrinae/1366902ff056d2cd054e75e47a33ce45 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
fs.readFile('./page-setup.css', { encoding: 'utf-8' }, (err, data) => { | |
console.log(cssMinifier(data)); | |
}); | |
function cssMinifier(cssString) { | |
const removeSpaceAroundChar = char => replace(new RegExp(`\\s*${char}\\s*`, 'g'), char); | |
const removeNewLine = replace(/[\r\n]/g, ''); | |
const shrinkers = map(removeSpaceAroundChar)([',', ';', ':', '{', '}']); | |
return pipe(trim, removeNewLine, ...shrinkers)(cssString); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment