Skip to content

Instantly share code, notes, and snippets.

@nezamy
Last active December 23, 2023 21:54
Show Gist options
  • Save nezamy/e34479c3bd83f8fcb5e36e050bf9d572 to your computer and use it in GitHub Desktop.
Save nezamy/e34479c3bd83f8fcb5e36e050bf9d572 to your computer and use it in GitHub Desktop.
Post Css & Sass & RTL Gulp Config
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);
@nezamy
Copy link
Author

nezamy commented Jun 12, 2020

Run gulp to compile or gulp watch to auto compile while files are changed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment