forked from colacao/loaderjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
62 lines (59 loc) · 1.81 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
var gulp = require("gulp"),
livereload = require("gulp-livereload"),
cssminify = require("gulp-minify-css"),
htmlmini = require("gulp-htmlmin"),
rename = require('gulp-rename'),
uglify = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
webp = require('gulp-webp'),
pngquant = require('imagemin-pngquant'),
cache = require('gulp-cache'),
zip = require('gulp-zip'),
caoyue = require("gulp-caoyue");
var config = require("./config.json");
gulp.task('watch', function() {
livereload.listen();
gulp.watch(['*.*']).on('change', livereload.changed);
});
gulp.task('default', function() {
gulp.run(['js','css','html','img']);
})
gulp.task('js', function() {
gulp.src('js/*.js')
.pipe(uglify())
.pipe(caoyue("m"))
.pipe(gulp.dest('dest/js'));
});
gulp.task('img', function() {
gulp.src('images/*.*')
.pipe(cache(imagemin({
use: [pngquant()],
optimizationLevel: 5, //类型:Number 默认:3 取值范围:0-7(优化等级)
progressive: true, //类型:Boolean 默认:false 无损压缩jpg图片
interlaced: true, //类型:Boolean 默认:false 隔行扫描gif进行渲染
multipass: true //类型:Boolean 默认:false 多次优化svg直到完全优化
})))
.pipe(gulp.dest('dest/images'));
gulp.src('images/*.*')
.pipe(webp())
.pipe(gulp.dest('dest/images'));
});
gulp.task('css', function() {
gulp.src('css/*.css')
.pipe(cssminify())
.pipe(gulp.dest('dest/css'));
});
gulp.task('html', function() {
gulp.src('temp/*.html')
.pipe(htmlmini())
.pipe(caoyue("t"))
.pipe(rename({
extname: '.html.js'
}))
.pipe(gulp.dest('dest/temp'));
});
gulp.task('zip', function() {
gulp.src(["dest/**","package.json","index.html"])
.pipe(zip('upload'+config.version+".zip"))
.pipe(gulp.dest('dist'));
});