forked from una/CSSgram
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
114 lines (100 loc) · 3.15 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
var gulp = require('gulp'),
sass = require('gulp-sass'),
rename = require('gulp-rename'),
cssmin = require('gulp-clean-css'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
cache = require('gulp-cached'),
prefix = require('gulp-autoprefixer'),
browserSync = require('browser-sync'),
reload = browserSync.reload,
size = require('gulp-size'),
imagemin = require('gulp-imagemin'),
minifyHTML = require('gulp-htmlmin'),
pngquant = require('imagemin-pngquant'),
plumber = require('gulp-plumber'),
deploy = require('gulp-gh-pages'),
notify = require('gulp-notify'),
sassLint = require('gulp-sass-lint'),
twig = require('gulp-twig');
gulp.task('lib-scss', function() {
var onError = function(err) {
notify.onError({
title: "Gulp",
subtitle: "Failure!",
message: "Error: <%= error.message %>",
sound: "Beep"
})(err);
this.emit('end');
};
return gulp.src('source/scss/**/*.scss')
.pipe(plumber({errorHandler: onError}))
.pipe(sass())
.pipe(size({ gzip: true, showFiles: true }))
.pipe(prefix())
.pipe(gulp.dest('source/css'))
.pipe(reload({stream:true}))
.pipe(cssmin())
.pipe(size({ gzip: true, showFiles: true }))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('source/css'))
.pipe(gulp.dest('site/css'));
});
gulp.task('site-scss', function() {
var onError = function(err) {
notify.onError({
title: "Gulp",
subtitle: "Failure!",
message: "Error: <%= error.message %>",
sound: "Beep"
})(err);
this.emit('end');
};
return gulp.src('site/scss/**/*.scss')
.pipe(plumber({errorHandler: onError}))
.pipe(sass())
.pipe(size({ gzip: true, showFiles: true }))
.pipe(prefix())
.pipe(gulp.dest('site/css'))
.pipe(reload({stream:true}))
.pipe(cssmin())
.pipe(size({ gzip: true, showFiles: true }))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('site/css'));
});
gulp.task('browser-sync', function() {
browserSync({
server: {
baseDir: "site"
}
});
});
gulp.task('deploy', function () {
return gulp.src('site/**/*')
.pipe(deploy());
});
gulp.task('sass-lint', function () {
gulp.src('scss/**/*.scss')
.pipe(sassLint())
.pipe(sassLint.format())
.pipe(sassLint.failOnError());
});
gulp.task('twig', function () {
gulp.src(['site/**/*.twig', "!site/twig/template.twig"], {base: './'})
.pipe(twig({
data: require('./site/filters.json')
}))
.pipe(gulp.dest('./'));
});
gulp.task('watch', function() {
gulp.watch('source/scss/**/*.scss', ['lib-scss', 'sass-lint']);
gulp.watch('site/scss/**/*.scss', ['site-scss', 'sass-lint']);
gulp.watch('source/scss/**/*.html', ['minify-html']);
gulp.watch('site/**/*.twig', ['twig']);
});
gulp.task('jshint', function() {
gulp.src('js/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
gulp.task('default', ['browser-sync', 'twig', 'lib-scss', 'site-scss', 'watch']);