-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
70 lines (58 loc) · 1.8 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
var gulp = require('gulp'),
sass = require('gulp-sass'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
rename = require('gulp-rename'),
sourcemaps = require('gulp-sourcemaps'),
cache = require('gulp-cache'),
csslint = require('gulp-csslint'),
concat = require('gulp-concat');
// css:
gulp.task('sass', function() {
return gulp.src('public/assets/css/src/*.scss')
.pipe(sass({outputStyle: 'compressed'}))
.pipe(gulp.dest('css'));
});
// js:
gulp.task('scripts', function() {
return gulp.src('public/assets/js/src/*.js')
.pipe(sourcemaps.init())
.pipe(concat('core.js'))
.pipe(sourcemaps.write({includeContent: false, sourceRoot: 'public/assets/js/src/*.js'}))
.pipe(gulp.dest('js'))
.pipe(rename({ suffix: '.min' }))
.pipe(uglify())
.pipe(gulp.dest('js'));
});
// images:
gulp.task('images', function() {
return gulp.src('images/src/*')
.pipe(cache(imagemin({ optimizationLevel: 3, multipass: true, svgoPlugins: [{removeViewBox: false}] })))
.pipe(gulp.dest('images'));
});
// lints:
gulp.task('jshint', function() {
return gulp.src('public/assets/js/src/*.js')
.pipe(jshint())
.pipe(jshint.reporter('default'))
});
gulp.task('csslint', function() {
gulp.src('public/assets/css/*.css')
.pipe(csslint())
.pipe(csslint.reporter());
});
// Watch
gulp.task('watch', function() {
gulp.watch('public/assets/css/src/**/*.scss', ['sass']);
gulp.watch('public/assets/js/src/*.js', ['scripts']);
gulp.watch('images/src/*', ['images']);
});
// testing task
gulp.task('test', function() {
gulp.start('scripts', 'jshint', 'sass', 'csslint');
});
// Default task
gulp.task('default', function() {
gulp.start('sass', 'scripts', 'images', 'watch');
});