Created
February 5, 2016 08:35
-
-
Save kozie/0c9e35b139cf8df92ad7 to your computer and use it in GitHub Desktop.
Gulpfile im using with Gulp 4 with error notifying and plumber
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
gulp = require 'gulp' | |
babel = require 'gulp-babel' | |
sourcemaps = require 'gulp-sourcemaps' | |
concat = require 'gulp-concat' | |
uglify = require 'gulp-uglify' | |
sass = require 'gulp-sass' | |
minCss = require 'gulp-minify-css' | |
prefix = require 'gulp-autoprefixer' | |
plumber = require 'gulp-plumber' | |
gutil = require 'gulp-util' | |
notify = require 'gulp-notify' | |
sync = require('browser-sync').create() | |
# Options | |
options = | |
SASS_SRC: './assets/style/style.scss' | |
SASS_FILES: './assets/style/**/*.scss' | |
SASS_DEST: './' | |
JS_SRC: './assets/js/**/*.js' | |
JS_DEST: './assets/' | |
JS_BUNDLE: 'bundle.min.js' | |
gulp.task 'style', (done) -> | |
gulp.src options.SASS_SRC | |
.pipe plumber() | |
.pipe sourcemaps.init() | |
.pipe sass( | |
outputStyle: 'expanded' | |
errLogToConsole: false, | |
).on('error', notify.onError()) | |
.pipe prefix browsers: ["last 2 versions", "> 5%"] | |
.pipe minCss keepSpecialComments: "*" | |
.pipe sourcemaps.write '.' | |
.pipe gulp.dest options.SASS_DEST | |
.pipe sync.stream() | |
.pipe notify message: 'Building CSS successful', onLast: true | |
done() | |
gulp.task 'scripts', (done) -> | |
gulp.src options.JS_SRC | |
.pipe plumber() | |
.pipe sourcemaps.init() | |
.pipe babel() | |
.on 'error', notify.onError() | |
.pipe concat options.JS_BUNDLE | |
.pipe sourcemaps.write '.' | |
.pipe gulp.dest options.JS_DEST | |
.pipe sync.stream() | |
.pipe notify message: 'Building JS successful', onLast: true | |
done() | |
gulp.task 'watch', -> | |
sync.init proxy: 'domain.local' | |
# Watch for sass changes | |
gulp.watch options.SASS_FILES, gulp.parallel 'style' | |
.on 'change', sync.reload | |
# Watch for js changes | |
gulp.watch options.JS_SRC, gulp.parallel 'scripts' | |
.on 'change', sync.reload | |
gulp.task 'build', gulp.parallel 'style', 'scripts', (done) -> | |
done() | |
gulp.task 'default', gulp.series 'build', 'watch', (done) -> | |
done() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment