-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
83 lines (72 loc) · 2.2 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
var gulp = require('gulp');
watch = require('gulp-watch'),
rename = require('gulp-rename'),
notify = require('gulp-notify'),
util = require('gulp-util'),
plumber = require('gulp-plumber'),
concat = require('gulp-concat'),
jshint = require('gulp-jshint'),
jscs = require('gulp-jscs'),
uglify = require('gulp-uglify'),
sourcemaps = require('gulp-sourcemaps'),
cache = require('gulp-cached'),
stylus = require('gulp-stylus'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
imagemin = require('gulp-imagemin');
function errorNotify(error){
notify.onError("Error: <%= error.message %>")
util.log(util.colors.red('Error'), error.message);
}
gulp.task('javascript', function() {
gulp.src('js/main.js')
.pipe(sourcemaps.init())
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jscs('.jscsrc'))
.on('error', errorNotify)
.pipe(uglify())
.on('error', errorNotify)
.pipe(rename({suffix: '.min'}))
.pipe(sourcemaps.write('/'))
.on('error', errorNotify)
.pipe(gulp.dest('js'))
.pipe(notify({ message: 'Javascript task complete' }));
});
gulp.task('javascript-library', function() {
gulp.src('js/library/*.js')
.pipe(concat('library.js'))
.pipe(gulp.dest('js'))
.pipe(notify({ message: 'Javascript Library task complete' }));
});
gulp.task('style', function() {
return gulp.src('css/site.styl')
.pipe(plumber())
.pipe(stylus())
.on('error', errorNotify)
.pipe(autoprefixer())
.on('error', errorNotify)
.pipe(gulp.dest('css'))
.pipe(rename({suffix: '.min'}))
.pipe(minifycss())
.on('error', errorNotify)
.pipe(gulp.dest('css'))
.pipe(notify({ message: 'Style task complete' }));
});
gulp.task('images', function () {
return gulp.src('src/images/*.*')
.pipe(cache('images'))
.pipe(imagemin({
progressive: false
}))
.on('error', errorNotify)
.pipe(gulp.dest('img/dist'))
.pipe(notify({ message: 'Images task complete' }));
});
gulp.task('watch', function() {
gulp.watch(['js/main.js'], ['javascript']);
gulp.watch(['js/library/*.js'], ['javascript-library']);
gulp.watch(['css/site.styl'], ['style']);
gulp.watch(['img/src/**'], ['images']);
});
gulp.task('default', ['watch']);