Last active
September 13, 2022 20:23
-
-
Save davidtorroija/dd54f271ae167ea88e2e5cd83bc1224a to your computer and use it in GitHub Desktop.
a task that I created in using gulp to easily change rem sizes based on 10px to 16px, this loop all the css and scss files and updates the measures using a regular expression, it works with calc, with 0.x .x etc
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 replace = require('gulp-replace'); | |
var gulp = require('gulp'); | |
var js = { | |
src: [ | |
'src/**/*.scss', | |
'src/**/*.css', | |
'src/**/*.tsx', //for the tsx files is in beta because it's including some strings like .remove or lorem ipsum, we need to tweak more the regexto exclude those | |
], | |
}; | |
// gulp.task('default', function () { | |
gulp.task('default', function () { | |
return gulp.src(js.src) | |
.pipe(replace(/(\d*\.?\d*)rem/gm, (item, number) => { | |
return ((number * 1) * 0.625) + 'rem'; | |
})) | |
.pipe(gulp.dest(function (file) { | |
return file.base; | |
})); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment