gulp压缩html ,css,js,img
Posted web前端pretty
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了gulp压缩html ,css,js,img相关的知识,希望对你有一定的参考价值。
(1) html
npm install gulp-html-minify --save-dev
var htmlminify=require("gulp-html-minify");
gulp.task("minhtml",function(){
gulp.src("src/*.html")
.pipe(htmlminify())
.pipe(gulp.dest("dist/"));});
(2)css
npm install gulp-clean-css --save-dev
var cleanCss=require("gulp-clean-css");
gulp.task("mincss",function(){
gulp.src("src/css/*.css")
.pipe(cleanCss())
.pipe(gulp.dest("dist/css"));});
(3)js
npm install gulp-uglify --save-dev
var uglify=require("gulp-uglify");
gulp.task("minjs",function(){
gulp.src("src/js/*.js")
.pipe(uglify())
.pipe(gulp.dest("dist/js"));});
(4)images
npm install gulp-imagemin --save-dev
gulp.task("image",function(){
gulp.src("src/images/*")
.pipe(imagemin())
.pipe(gulp.dest("dist/images"));});
以上是关于gulp压缩html ,css,js,img的主要内容,如果未能解决你的问题,请参考以下文章