-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
69 lines (61 loc) · 2.13 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
65
66
67
68
69
'use strict';
const autoprefixer = require('gulp-autoprefixer'),
babel = require('gulp-babel'),
concat = require('gulp-concat'),
cssnano = require('gulp-cssnano'),
eslint = require('gulp-eslint'),
gulp = require('gulp'),
notify = require('gulp-notify'),
plumber = require('gulp-plumber'),
rename = require('gulp-rename'),
runSequence = require('run-sequence'),
sass = require('gulp-sass'),
stylelint = require('gulp-stylelint'),
uglify = require('gulp-uglify');
function customPlumber(errTitle) {
return plumber({
errorHandler: notify.onError({
title: errTitle || "Ouch! Error running Gulp",
message: "Error: <%= error.message %>"
})
});
}
gulp.task('scripts', function() {
return gulp.src('src/*.js')
.pipe(babel({
presets: ['env']
}))
.pipe(eslint())
.pipe(eslint.format())
.pipe(concat('share.js'))
.pipe(gulp.dest('public/'))
.pipe(rename({suffix: '.min'}) )
.pipe(uglify())
.pipe(gulp.dest('public/'))
});
gulp.task('styles:lint', function() {
return gulp.src('src/*.scss')
.pipe(stylelint({
failAfterError: false,
reporters: [
{formatter: 'verbose', console: true}
]
}));
});
gulp.task('styles:build', function() {
return gulp.src('src/styles.scss')
.pipe(customPlumber('Ouch! Error Running StyleLint'))
.pipe(sass({errLogToConsole: true}))
.pipe(autoprefixer(['last 3 versions', 'IE 10', 'iOS 9', 'Android 4']))
.pipe(gulp.dest('public/'))
.pipe(rename({ suffix: '.min' }))
.pipe(cssnano())
.pipe(gulp.dest('public/'))
});
gulp.task('watch', function() {
gulp.watch('./src/*.scss', ['styles:build']);
gulp.watch('./src/*.js', ['scripts']);
});
gulp.task('default', function() {
runSequence('styles:lint', 'styles:build', 'scripts', 'watch');
});