-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
executable file
·74 lines (67 loc) · 2.09 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
// Load plugins
var gulp = require('gulp'),
sass = require('gulp-sass'),
minifycss = require('gulp-minify-css'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
rename = require('gulp-rename'),
notify = require('gulp-notify');
// Source paths
var jsSrc = [
'resources/scripts/src/*.js'
],
sassSrc = [
'resources/stylesheets/src/*.scss'
];
// Compile and minify Sass
gulp.task('styles', function () {
gulp.src(sassSrc)
.pipe(sass({
style: 'expanded',
lineNumbers: true,
sourcemap: false,
includePaths: require('node-neat').includePaths
}))
.pipe(gulp.dest('resources/stylesheets'))
.pipe(rename({ suffix: '.min' }))
.pipe(minifycss())
.pipe(gulp.dest('resources/stylesheets'))
.pipe(notify({ message: 'Styles task complete' }));
});
// Lint
gulp.task('lint', function() {
return gulp.src(jsSrc)
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(notify(
function (file) {
if (file.jshint.success) {
return false;
}
var errors = file.jshint.results.map(function (data) {
if (data.error) {
return "(" + data.error.line + ':' + data.error.character + ') ' + data.error.reason;
}
}).join("\n");
return file.relative + " (" + file.jshint.results.length + " errors)\n" + errors;
}
));
});
// Concat and uglify scripts
gulp.task('scripts', function () {
gulp.src(jsSrc)
.pipe(concat('all.js'))
.pipe(rename({ suffix: '.min' }))
.pipe(uglify())
.pipe(gulp.dest('resources/scripts'))
.pipe(notify({ message: 'Scripts task complete' }));
});
// Watch for changes
gulp.task('watch', function() {
gulp.watch(jsSrc, ['lint']);
gulp.watch(sassSrc, ['styles']);
gulp.watch(jsSrc, ['scripts']);
});
// Default task
gulp.task('default', ['styles', 'lint', 'scripts', 'watch']);