-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
64 lines (56 loc) · 1.71 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const gulp = require('gulp');
const runSequence = require('run-sequence');
const watch = require('gulp-watch');
const sass = require('gulp-sass');
const sourcemaps = require('gulp-sourcemaps');
const autoprefixer = require('gulp-autoprefixer');
const notify = require('gulp-notify');
const cssnano = require('gulp-cssnano');
const plumber = require('gulp-plumber');
const scssFiles = ['./assets/scss/**/*.scss'];
const scssMain = ['./assets/scss/main.scss'];
const pathStyleDest = './assets/css';
// SASS
gulp.task('style', function () {
return gulp.src(scssMain)
.pipe(plumber({errorHandler: notify.onError("Style Build Error: <%= error.message %>")}))
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(autoprefixer('last 4 version'))
.pipe(sourcemaps.write())
.on('error', onError)
.pipe(gulp.dest(pathStyleDest));
});
gulp.task('style-build', function () {
return gulp.src(scssMain)
.pipe(plumber({errorHandler: notify.onError("Style Build Error: <%= error.message %>")}))
.pipe(sass())
.on('error', onError)
.pipe(autoprefixer('last 4 version'))
.pipe(cssnano())
.pipe(gulp.dest(pathStyleDest));
});
// Watcher
gulp.task('watch', () => {
gulp.watch(scssFiles, function(){
runSequence('style', ['notify']);
});
});
// Build for prod
gulp.task('build', function(callback) {
runSequence(['style-build'], callback)
});
// Default
gulp.task('default', done => {
runSequence(['style', 'watch'], done);
});
///////////////////////////////////////////////////////////
// Helpers
function onError(error) {
console.log(error.toString());
this.emit('end');
}
gulp.task('notify', function () {
return gulp.src('')
.pipe(notify({message: 'DRAKARYS!!!', onLast: true}));
});