We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gulp崇尚的是每个插件只做一件事,并且把这件事做的很好,代码压缩只是做压缩,不做其他的事情,代码压缩后,如果直接输出,压缩后的代码会覆盖原来的代码,于是还要配合gulp-rename使用,rename专门负责文件名称的更改
npm install gulp gulp-minify-css gulp-rename
var gulp = require('gulp'), rename = require('gulp-rename'), minify = require('gulp-minify-css'); gulp.task('minify',function(){ gulp.src(['*.css','!*.min.css']) .pipe(minify()) .pipe(rename({ suffix:'.min' })) .pipe(gulp.dest('/dist')) })
执行:
gulp minify
在npm安装gulp,gulp-rename的基础上
npm install gulp-uglify
var gulp = require('gulp'), rename = require('gulp-rename'), uglify = require('gulp-uglify'); gulp.task('uglify',function(){ gulp.src(['*.js','!*.min.js']) .pipe(uglify()) .pipe(rename({ suffix:'.min' })) .pipe(gulp.dest('/dist')) })
gulp uglify
npm install gulp-concat
var gulp = require('gulp'), concat = require('gulp-concat'); gulp.task('concat',function(){ gulp.src(['*.css']) .pipe(concat('all.css')) .pipe(gulp.dest('/dist')) })
gulp concat
The text was updated successfully, but these errors were encountered:
No branches or pull requests
平时工作中,会遇到代码压缩,代码合并等需求,使用gulp的插件能很好的满足这些需求
gulp崇尚的是每个插件只做一件事,并且把这件事做的很好,代码压缩只是做压缩,不做其他的事情,代码压缩后,如果直接输出,压缩后的代码会覆盖原来的代码,于是还要配合gulp-rename使用,rename专门负责文件名称的更改
css压缩
执行:
在npm安装gulp,gulp-rename的基础上
javascript压缩
执行:
代码合并
执行:
工作中还有很多需求,都可以借助gulp的插件来完成。都可以在gulp的插件找到合适的
The text was updated successfully, but these errors were encountered: