-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
80 lines (72 loc) · 2.11 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
70
71
72
73
74
75
76
77
78
79
80
var autoPrefixBrowserList = ['last 2 version'];
var gulp = require('gulp'),
gutil = require('gulp-util'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
sass = require('gulp-sass'),
sassGlob = require('gulp-sass-glob'),
minifyCSS = require('gulp-minify-css'),
browserSync = require('browser-sync'),
autoprefixer = require('gulp-autoprefixer'),
gulpSequence = require('gulp-sequence').use(gulp),
shell = require('gulp-shell'),
plumber = require('gulp-plumber'),
stylelint = require('gulp-stylelint'),
cssstats = require('gulp-cssstats');
gulp.task('browserSync', function() {
browserSync({
server: { baseDir: './' },
reloadDelay: 1000,
notify: false
});
});
gulp.task('stylelint', function() {
return gulp.src(['./modules/**/*.scss'])
.pipe(stylelint({
configFile: './.stylelintrc',
syntax: 'scss',
reporters: [
{formatter: 'string', console: true}
]
}))
});
gulp.task('styles', function() {
return gulp.src('modules/all.scss')
.pipe(plumber({
errorHandler: function (err) {
console.log(err);
this.emit('end');
}
}))
.pipe(sassGlob())
.pipe(sass({
errLogToConsole: true,
includePaths: [ './modules/' ]
}))
.pipe(autoprefixer({
browsers: autoPrefixBrowserList,
cascade: true
}))
.on('error', gutil.log)
.pipe(concat('decent.css'))
.pipe(minifyCSS())
.pipe(gulp.dest('./css'))
.pipe(browserSync.reload({stream: true}));
});
gulp.task('stats', function() {
return gulp.src('./css/decent.css')
.pipe(cssstats())
.pipe(gulp.dest('css'))
});
// Refresh browser on html changes.
gulp.task('html', function() {
return gulp.src('src/*.html')
.pipe(plumber())
.pipe(browserSync.reload({stream: true}))
.on('error', gutil.log);
});
gulp.task('default', ['styles', 'stats'], function() {
gulp.watch(['./modules/**/*', './functions/**/*'], ['stylelint', 'styles', 'stats']);
gulp.watch('src/*.html', ['html']);
gulp.watch();
});