Last active
December 23, 2023 21:54
-
-
Save nezamy/e34479c3bd83f8fcb5e36e050bf9d572 to your computer and use it in GitHub Desktop.
Post Css & Sass & RTL Gulp Config
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
const { src, dest, watch, series, task } = require('gulp'); | |
const postcss = require('gulp-postcss'); | |
const autoprefixer = require('autoprefixer'); | |
const cssnext = require('cssnext'); | |
const precss = require('precss'); | |
const cssnano = require('cssnano'); | |
const sass = require('gulp-sass'); | |
const fontMagician = require('postcss-font-magician'); | |
const rtlcss = require('rtlcss'); | |
const rename = require('gulp-rename'); | |
var processors = [ | |
autoprefixer, | |
cssnext, | |
precss, | |
fontMagician, | |
]; | |
var processors_rtl = [rtlcss].concat(processors); | |
function css_ltr(cb){ | |
cb(); | |
return src('./src/css/*.scss') | |
.pipe(sass().on('error', sass.logError)) | |
.pipe(postcss(processors)) | |
.pipe(dest('./dest/css')) | |
.pipe(postcss([cssnano])) | |
.pipe(rename({ extname: '.min.css' })) | |
.pipe(dest('./dest/css')); | |
} | |
function css_rtl(cb){ | |
cb(); | |
return src('./src/css/*.scss') | |
.pipe(sass().on('error', sass.logError)) | |
.pipe(postcss(processors_rtl)) | |
.pipe(rename({ extname: '-rtl.css' })) | |
.pipe(dest('./dest/css')) | |
.pipe(postcss([cssnano])) | |
.pipe(rename({ extname: '.min.css' })) | |
.pipe(dest('./dest/css')); | |
} | |
task('watch', function () { | |
return watch('./src/css/*.scss', series(css_ltr, css_rtl)); | |
}); | |
exports.default = series(css_ltr, css_rtl); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run
gulp
to compile orgulp watch
to auto compile while files are changed