gulp学习
2015-12-08
gulp-bump
看名字很糊涂。。其实是一个更新版本的插件
gulp.task('bump', function(){
return gulp.src('./package.json')
.pipe(bump({type: 'patch'}))
.pipe(gulp.dest('./'))
})
//bump(opts) 这个函数中是可以传入参数的
//1.version 比如说{version: 1.0.1}
//2.type 这其中有4个
//prerelease:1.2.3-0
//patch:1.2.4
//minor:1.3.0
//major:2.0.0
//3.indent改变原来的json文件的缩进{indent: 4}
//也可以在src中传入多个文件比如 bower.json
gulp-uglify
js压缩插件。。
return gulp.src('./lib/*.js')
.pipe(uglify())
.pipe(gulp.dest('./dest'))
gulp-rename
// rename via string
gulp.src("./src/main/text/hello.txt")
.pipe(rename("main/text/ciao/goodbye.md"))
.pipe(gulp.dest("./dist")); // ./dist/main/text/ciao/goodbye.md
// rename via function
gulp.src("./src/**/hello.txt")
.pipe(rename(function (path) {
path.dirname += "/ciao";
path.basename += "-goodbye";
path.extname = ".md"
}))
.pipe(gulp.dest("./dist")); // ./dist/main/text/ciao/hello-goodbye.md
// rename via hash
gulp.src("./src/main/text/hello.txt", { base: process.cwd() })
.pipe(rename({
dirname: "main/text/ciao",
basename: "aloha",
prefix: "bonjour-",
suffix: "-hola",
extname: ".md"
}))
.pipe(gulp.dest("./dist")); // ./dist/main/text/ciao/bonjour-aloha-hola.md
gulp-uglify和gulp-rename一起用可以输出源文件和min.js文件