-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
59 lines (53 loc) · 1.59 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
'use strict';
var gulp = require('gulp'),
plumber = require('gulp-plumber'),
rename = require('gulp-rename'),
// CSS
sass = require('gulp-sass'),
prefixer = require('gulp-autoprefixer'),
// JS
uglify = require('gulp-uglify'),
jshint = require('gulp-jshint'),
// Images
imagemin = require('gulp-imagemin');
gulp.task('css', function() {
return gulp.src('./src/css/**/*.scss')
.pipe(sass({
outputStyle: 'compressed',
includePaths: [__dirname + '/vendor/titon/toolkit/scss/']
}))
.pipe(prefixer({
browsers: ['last 3 versions'],
cascade: false
}))
.pipe(rename(function(file) {
file.basename += '.min';
}))
.pipe(gulp.dest('./web/css/'));
});
gulp.task('js', function() {
return gulp.src('./src/js/**/*.js')
.pipe(plumber())
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(uglify())
.pipe(rename(function(file) {
file.basename += '.min';
}))
.pipe(gulp.dest('./web/js/'));
});
gulp.task('img', function() {
return gulp.src('./src/img/**/*.{gif,jpg,jpeg,png,svg}')
.pipe(plumber())
.pipe(imagemin({
optimizationLevel: 4,
progressive: true
}))
.pipe(gulp.dest('./web/img/'));
});
gulp.task('default', ['css', 'js', 'img']);
gulp.task('watch', ['default'], function() {
gulp.watch('./src/js/**/*.js', ['js']);
gulp.watch('./src/css/**/*.scss', ['css']);
gulp.watch('./src/img/**/*.{gif,jpg,jpeg,png,svg}', ['img']);
});