Created
February 25, 2020 08:55
-
-
Save Walkeryr/4d6f2eea6450e9caa7aba875213d0f30 to your computer and use it in GitHub Desktop.
Script to convert all rems to pixels
This file contains 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
var fs = require('fs'); | |
let doc = fs.readFileSync('dist/css/app.b528a7e0.css', 'utf8'); | |
console.log(doc.replace(/(:|\s?){1}([0-9-]*\.?[0-9]*)(rem)/g, function (match, delimeterGroup, numberGroup, sizeGroup, offset, string) { | |
let pixelSize = Number(numberGroup) * 16 | |
if (delimeterGroup === ':') { | |
return `:${pixelSize}px` | |
} else if (delimeterGroup === ' ') { | |
return ` ${pixelSize}px` | |
} | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment