Gulp - 在新的形成时删除旧的bundle

时间:2016-09-21 06:34:38

标签: gulp gulp-concat gulp-clean-css gulp-newer gulp-ng-annotate

我真的很新,我正在努力制作一个看似相当简单的构建过程,但我无法破解它。

我想要实现的是,要捆绑和捆绑以命名为all_*.min.js where *的所有js和css文件都是当前时间戳并删除旧的all_*.min.js捆绑包。

我的另一个挑战是如何在没有监视的情况下更改其中一个bundle文件时检测bundle中的更改。简而言之,这就是我想要实现的目标。任何建议都会有很大的帮助。

提前致谢。

gulp.task('scripts', function () {
gulp.src(['js/*.js']) // folder of individual js files
.pipe(changed('build/js/')) // build folder for all the bundles
.pipe(ngAnnotate())  // get only those files which are changed
.pipe(deletefile({ reg: '*.min.js', deleteMatch: false })) // delete old bundles which contains changes
.pipe(concat('scripts.js')) // concatnate files to form new bundle
.pipe(uglify()) // uglify it
.pipe(rename({ suffix: (new Date()).getTime() + '.min'})) // do versioning 
.pipe(gulp.dest('build/js/')); // place it in final build folder
});

0 个答案:

没有答案
相关问题