-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
132 lines (114 loc) · 3.48 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
126
127
128
129
130
131
132
var gulp = require('gulp');
var watch = require('gulp-watch');
var rename = require('gulp-rename');
var notify = require('gulp-notify');
var util = require('gulp-util');
var plumber = require('gulp-plumber');
var concat = require('gulp-concat');
var jshint = require('gulp-jshint');
var jscs = require('gulp-jscs');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');
var mainBowerFiles = require('main-bower-files');
var cache = require('gulp-cached');
var stylus = require('gulp-stylus');
var autoprefixer = require('gulp-autoprefixer');
var minifycss = require('gulp-minify-css');
var swiss = require('kouto-swiss');
var stylint = require('gulp-stylint');
var imagemin = require('gulp-imagemin');
var phplint = require('gulp-phplint');
function errorNotify(error){
notify.onError("Error: <%= error.message %>")
util.log(util.colors.red('Error'), error.message);
}
// JAVASCRIPT
gulp.task('javascript', function() {
return 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() {
return gulp.src(mainBowerFiles('**/*.js'))
.pipe(sourcemaps.init())
.pipe(concat('library.js'))
.pipe(gulp.dest('js'))
.pipe(uglify({mangle: false}))
.on('error', errorNotify)
.pipe(rename({suffix: '.min'}))
.pipe(sourcemaps.write('/'))
.on('error', errorNotify)
.pipe(gulp.dest('js'))
.pipe(notify({ message: 'Javascript Library task complete' }));
});
// STYLES
gulp.task('style-lint', function () {
return gulp.src(['css/site.styl', 'css/responsive/*.styl'])
.pipe(cache('style-lint'))
.pipe(plumber())
.pipe(stylint({config: '.stylintrc'}))
.on('error', errorNotify)
.pipe(stylint.reporter())
.on('error', errorNotify)
.pipe(notify({ message: 'Style lint task complete' }));
});
gulp.task('style', function() {
return gulp.src(['css/site.styl'])
.pipe(plumber())
.pipe(stylus({
use: [
swiss()
],
}))
.on('error', errorNotify)
.pipe(autoprefixer({
browsers: ['last 5 versions'],
}))
.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('style-library', function() {
return gulp.src(mainBowerFiles('**/*.css'))
.pipe(plumber())
.pipe(concat('library.styl'))
.on('error', errorNotify)
.pipe(gulp.dest('css'))
.pipe(notify({ message: 'Style library task complete' }));
});
// IMAGES
gulp.task('images', function () {
return gulp.src('img/src/*.*')
.pipe(cache('images'))
.pipe(plumber())
.pipe(imagemin({
progressive: false
}))
.on('error', errorNotify)
.pipe(gulp.dest('img/dist'))
.pipe(notify({ message: 'Images task complete' }));
});
// TASKS
gulp.task('watch', function() {
gulp.watch(['js/main.js'], ['javascript']);
gulp.watch(['css/*.styl', 'css/responsive/*.styl'], ['style']);
gulp.watch(['css/*.styl', 'css/responsive/*.styl'], ['style-lint']);
gulp.watch(['img/src/*.*'], ['images']);
});
gulp.task('build', ['build-style', 'javascript', 'javascript-library']);
gulp.task('build-style', ['style-library', 'style']);
gulp.task('default', ['watch']);