先安装gulp
// gulp指南链接
https://www.kancloud.cn/thinkphp/gulp-guide/43995
var gulp = require('gulp'),
minifycss = require('gulp-minify-css'),
rename = require('gulp-rename');
//压缩css
gulp.task('minifycss', function() {
return gulp.src('css/style.css') //需要操作的文件
.pipe(rename({suffix: '.min'})) //rename压缩后的文件名
.pipe(minifycss()) //执行压缩
.pipe(gulp.dest('Css')); //输出文件夹
});
gulp.task('default',['jshint'],function() {
gulp.start('minifycss');
});
gulp压缩js
//压缩js文件
// 先引入 gulp-uglify 文件,npm install gulp-uglify
gulp.task('script',function(){
gulp.src('js/distpicker.js')
.pipe(uglify())
.pipe(rename({suffix:'.min'}))
.pipe(gulp.dest('js'));
});
gulp.task('default',['bowerCopy','sass-complie','src-move']);
//最后在控制台输入 gulp script