Skip to content

Instantly share code, notes, and snippets.

@zmnv
Last active February 7, 2019 14:39
Show Gist options
  • Save zmnv/e4d6508075a6c04f1db7c4ebc0617a1f to your computer and use it in GitHub Desktop.
Save zmnv/e4d6508075a6c04f1db7c4ebc0617a1f to your computer and use it in GitHub Desktop.
Gulp 4 CSS to SCSS with watch
const gulp = require('gulp'),
sass = require('gulp-sass'),
concat = require('gulp-concat'),
prefix = require('gulp-autoprefixer'),
rename = require('gulp-rename');
plumber = require('gulp-plumber');
function css() {
return gulp
.src('./scss/**/*.scss')
.pipe(plumber())
.pipe(sass({ outputStyle: 'compressed' }).on('error', sass.logError))
.pipe(prefix('last 2 versions'))
.pipe(concat('main.css'))
// .pipe(gulp.dest('./'))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('./'))
}
function watchFiles() {
gulp.watch('./scss/**/*', css);
}
exports.watch = watchFiles;
exports.default = css;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment