Skip to content

Instantly share code, notes, and snippets.

@davidtorroija
Last active September 13, 2022 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidtorroija/dd54f271ae167ea88e2e5cd83bc1224a to your computer and use it in GitHub Desktop.
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
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