gulpfile.js:
var gulp = require(‘gulp‘),
minifycss = require(‘gulp-minify-css‘),
uglify = require(‘gulp-uglify‘);
var assetRev = require(‘gulp-asset-rev‘);
gulp.task(‘rev‘,[‘revCss‘,‘revJs‘,‘revImg‘],function() {
gulp.src("./*.html")
.pipe(assetRev())
.pipe(gulp.dest(‘./dest‘));
});
gulp.task(‘revCss‘,function () {
return gulp.src(‘./css/*.css‘)
.pipe(minifycss())
.pipe(assetRev())
.pipe(gulp.dest(‘./dest/css/‘))
});
gulp.task(‘revJs‘,function () {
return gulp.src(‘./js/*.js‘)
.pipe(uglify())
.pipe(assetRev())
.pipe(gulp.dest(‘./dest/js/‘))
});
gulp.task(‘revImg‘,function () {
return gulp.src(‘./img/*‘)
//.pipe(assetRev())
.pipe(gulp.dest(‘./dest/img/‘))
});
gulp.task(‘default‘,[‘rev‘]);
/**
*
* 只添加版本号不压缩
*
*/
/*var gulp = require(‘gulp‘);
var assetRev = require(‘gulp-asset-rev‘);
gulp.task(‘rev‘,[‘revCss‘,‘revJs‘,‘revImg‘],function() {
gulp.src("./*.html")
.pipe(assetRev())
.pipe(gulp.dest(‘./dest‘));
});
gulp.task(‘revCss‘,function () {
return gulp.src(‘./css/*.css‘)
.pipe(assetRev())
.pipe(gulp.dest(‘./dest/css/‘))
});
gulp.task(‘revJs‘,function () {
return gulp.src(‘./js/*.js‘)
.pipe(assetRev())
.pipe(gulp.dest(‘./dest/js/‘))
});
gulp.task(‘revImg‘,function () {
return gulp.src(‘./img/*‘)
//.pipe(assetRev())
.pipe(gulp.dest(‘./dest/img/‘))
});
gulp.task(‘default‘,[‘rev‘]);*/
本文出自 “8159085” 博客,转载请与作者联系!
原文地址:http://8169085.blog.51cto.com/8159085/1829144