Last active
February 7, 2019 14:39
-
-
Save zmnv/e4d6508075a6c04f1db7c4ebc0617a1f to your computer and use it in GitHub Desktop.
Gulp 4 CSS to SCSS with watch
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 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