Reputation: 51
I want to create zip of all the files and folders inside the /dist folder.
I have folder structure like :
/dist
/audio/
/css/
/icons/
/js/
/libs/
/locales/en-US
/locales/mr
/locales/hi
/locales/te
/locales/fr
I basically want to use gulp-zip to zip up my entire /dist folder and sub-folders and save the zip inside it. So this is what i am doing :
var bases = {
app: 'app/',
dist: 'dist/',
};
gulp.task('zip', function () {
return gulp.src(bases.dist + '**')
.pipe(using())
.pipe(zip('buildTest.zip'))
.pipe(gulp.dest('./' + bases.dist));
});
with this i am able to create buildTest.zip but it don't include all the sub-folders from /locales.Please advice.
Upvotes: 3
Views: 852
Reputation: 18661
Gulp runs dependency tasks in asynchronous fashion as much as possible, so instead of using zip as dependency task, make zip task to depend on build task and have the default task run the zip task, as follow
const gulp = require('gulp');
const zip = require('gulp-zip');
gulp.task('build', ['copyAssets', 'minify-js', 'minify-css']);
gulp.task('zip', ['build'], function() {
gulp.src('dist/**')
.pipe(zip('archive.zip'))
.pipe(gulp.dest('./'))
});
gulp.task('default', ['clean'], function () {
gulp.start('zip');
});
Upvotes: 3