-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
88 lines (81 loc) · 2.24 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
var gulp = require('gulp'),
gulpLoadPlugins = require("gulp-load-plugins"),
$ = gulpLoadPlugins({
lazy: false, // whether the plugins should be lazy loaded on demand
});
// My asset directories
var sassFiles = 'assets/sass/**/*.scss',
jsFiles = 'assets/js/**/*.js',
imgFiles = 'assets/img/**/*.{png,gif,jpg,jpeg}',
bowerFile = './bower.json',
phpFiles = ['src/**/*.php', 'tests/**/*.php'];
// Compiled asset directories
targetAssetDir = 'public',
targetCSSDir = targetAssetDir+'/css',
targetJSDir = targetAssetDir+'/js',
targetImgDir = targetAssetDir+'/img',
targetBowerDir = targetAssetDir+'/vendor';
// CSS
gulp.task('css', function() {
return gulp.src(sassFiles)
.pipe($.plumber())
.pipe($.rubySass({ style: 'compressed' }).on('error', $.util.log).on('error', $.notify.onError({
title: "Failed compiling SASS!",
message: "<%= error.message %>"
})))
.pipe($.csslint({
'adjoining-classes': false // This only affects <= IE6
}))
.pipe($.csslint.reporter())
.pipe($.autoprefixer('last 10 versions', 'ie 8'))
.pipe($.size({
showFiles: true
}))
.pipe(gulp.dest(targetCSSDir));
});
// Javascript
gulp.task('js', function() {
return gulp.src(jsFiles)
.pipe($.jshint())
.pipe($.jshint.reporter('default'))
.pipe($.uglify())
.pipe($.size({
showFiles: true
}))
.pipe(gulp.dest(targetJSDir));
});
gulp.task('bower', function() {
$.bower()
.pipe(gulp.dest(targetBowerDir));
});
// Images
gulp.task('images', function () {
return gulp.src(imgFiles)
.pipe($.cache($.imagemin({
optimizationLevel: 3,
progressive: true,
interlaced: true
})))
.pipe($.size({
showFiles: true
}))
.pipe(gulp.dest(targetImgDir));
});
// Unit tests
gulp.task('phpunit', function() {
var options = {debug: false, notify: true};
gulp.src('tests/**/*.php')
.pipe($.phpunit('phpunit', options)).on('error', $.notify.onError({
title: "Failed Tests!",
message: "Error(s) occurred during testing..."
}));
});
// Watch for changes and recompile
gulp.task('watch', function() {
gulp.watch(sassFiles, ['css']);
gulp.watch(jsFiles, ['js']);
gulp.watch(bowerFile, ['bower']);
gulp.watch(imgFiles, ['images']);
gulp.watch(phpFiles, ['phpunit']);
});
gulp.task('default', ['css', 'js', 'bower', 'images', 'phpunit', 'watch']);