-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·87 lines (76 loc) · 2.33 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
var gulp = require('gulp'),
less = require('gulp-less'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
rename = require('gulp-rename'),
rimraf = require('gulp-rimraf'),
ignore = require('gulp-ignore'),
concat = require('gulp-concat'),
newer = require('gulp-newer'),
plumber = require('gulp-plumber');
gulp.task('styles', function() {
return gulp.src('app/less/app.less')
.pipe(plumber())
.pipe(less({ style: 'expanded' }))
.pipe(autoprefixer('last 4 version'))
.pipe(gulp.dest('www/styles'))
.pipe(rename({suffix: '.min'}))
.pipe(minifycss())
.pipe(gulp.dest('www/styles'));
});
gulp.task('scripts', function() {
return gulp.src(['app/scripts/default.js',
])
.pipe(plumber())
.pipe(concat('app.js'))
.pipe(gulp.dest('www/scripts'))
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest('www/scripts'));
});
gulp.task('images', function() {
return gulp.src('app/assets/img/**/*')
.pipe(plumber())
.pipe(newer('app/assets/img/**/*'))
.pipe(imagemin({
optimizationLevel: 7,
progressive: true,
interlaced: true,
svgoPlugins: [{removeViewBox: false}]
}))
.pipe(gulp.dest('www/assets/img'));
});
gulp.task('html', function () {
return gulp.src('app/html/**/*')
.pipe(plumber())
.pipe(newer('app/html/**/*'))
.pipe(gulp.dest('www'));
});
gulp.task('clean', function() {
return gulp.src(['www/styles', 'www/scripts', 'www/assets/img'], { read: false })
.pipe(rimraf());
});
gulp.task('default', ['clean'], function() {
gulp.start('styles', 'scripts', 'images', 'html');
});
gulp.task('watch', function() {
gulp.watch('app/less/**/*.less', ['styles']);
gulp.watch('app/scripts/**/*.js', ['scripts']);
gulp.watch('app/assets/img/**/*', ['images']);
gulp.watch('app/html/**/*', ['html']);
});
gulp.task('watch-styles', function() {
gulp.watch('app/less/**/*.less', ['styles']);
});
gulp.task('watch-scripts', function() {
gulp.watch('app/scripts/**/*.js', ['scripts']);
});
gulp.task('watch-html', function() {
gulp.watch('app/html/**/*', ['html']);
});
gulp.task('watch-images', function() {
gulp.watch('app/assets/img/**/*', ['images']);
});