-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
125 lines (112 loc) · 3.33 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
115
116
117
118
119
120
121
122
123
124
125
var Promise = require('es6-promise').Promise;
// Include gulp.
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
// Include config.
var config = require('./config.json');
// Include plugins.
var sass = require('gulp-sass');
var imagemin = require('gulp-imagemin');
var pngcrush = require('imagemin-pngcrush');
var shell = require('gulp-shell');
var plumber = require('gulp-plumber');
var notify = require('gulp-notify');
var autoprefix = require('gulp-autoprefixer');
var glob = require('gulp-sass-glob');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var sourcemaps = require('gulp-sourcemaps');
var scsslint = require('gulp-scss-lint');
var jshint = require('gulp-jshint');
var run = require('gulp-run');
// CSS.
gulp.task('css', function() {
return gulp.src(config.css.src)
.pipe(glob())
.pipe(plumber({
errorHandler: function (error) {
notify.onError({
title: "Gulp",
subtitle: "Failure!",
message: "Error: <%= error.message %>",
sound: "Beep"
}) (error);
this.emit('end');
}}))
.pipe(sourcemaps.init())
.pipe(sass({
style: 'compressed',
errLogToConsole: true,
includePaths: config.css.includePaths
}))
.pipe(autoprefix('last 2 versions', '> 1%', 'ie 9', 'ie 10'))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(config.css.dest));
});
// JS
gulp.task('js', function() {
return gulp.src(config.js.src)
.pipe(sourcemaps.init())
.pipe(concat(config.js.file))
.pipe(plumber({
errorHandler: function (error) {
notify.onError({
title: "JS",
subtitle: "Failure!",
message: "Error: <%= error.message %>",
sound: "Beep"
}) (error);
this.emit('end');
}}))
.pipe(uglify())
.pipe(sourcemaps.write())
.pipe(gulp.dest(config.js.dest));
});
// Compress images.
gulp.task('images', function () {
return gulp.src(config.images.src)
.pipe(imagemin({
progressive: true,
svgoPlugins: [{ removeViewBox: false }],
use: [pngcrush()]
}))
.pipe(gulp.dest(config.images.dest));
});
// Fonts.
gulp.task('fonts', function() {
return gulp.src(config.fonts.src)
.pipe(gulp.dest(config.fonts.dest));
});
// Static Server + Watch
gulp.task('serve', ['css', 'js', 'fonts'], function() {
browserSync.init({
proxy: config.browserSyncProxy
});
gulp.watch(config.js.src, ['js']);
gulp.watch(config.css.src, ['css']);
gulp.watch(config.images.src, ['images']);
gulp.watch('assets/**/*').on('change', browserSync.reload);
});
// Run drush to clear the theme registry.
gulp.task('drush', shell.task([
'drush cache-clear theme-registry'
]));
// SCSS Linting.
gulp.task('scss-lint', function() {
return gulp.src(['./scss/**/*.scss', '!./scss/radix/**/*.scss'])
.pipe(scsslint())
.pipe(scsslint.failReporter());
});
// JS Linting.
gulp.task('js-lint', function() {
return gulp.src('./assets/js/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
// Styleguide creation.
gulp.task('kss', function () {
run('kss-node scss/ styleguide/ --css ../assets/css/sport_2014.style.css --mask *.scss --homepage=styleguide.md --title="Styleguide for vih.dk"').exec();
});
// Default Task
gulp.task('default', ['serve']);