I'm using Gulp to compile a project. I'm also using gulp-zip to zip a bunch of files.
I want to zip up all the files in the "dist" folder, so I'm using this:
var thesrc: ['dist/**/*'];
gulp.task('createMainZip', ['createPluginZip'], function () {
return gulp.src(thesrc)
.pipe(zip('main_files.zip'))
.pipe(gulp.dest('compiled'));
});
This compiles the files to a zip in the following way:
- dist
- file.css
- another.js
- folder
However, I want it like this:
- file.css
- another.js
- folder
Without the dist folder. Is there a way to do this using a different src path?
Thanks for your help.
gulp-zip doesn't honor base
. See for some background:
- https://github.com/sindresorhus/gulp-zip/issues/10
- https://github.com/sindresorhus/gulp-zip/pull/11
- https://github.com/sindresorhus/gulp-zip/blob/master/index.js#L30
Now, you can do something like that (admittedly ugly):
var gulp = require('gulp');
var zip = require('gulp-zip');
var thesrc = ['**/*'];
gulp.task('createMainZip', function () {
return gulp.src(thesrc, {cwd: __dirname + "/dist"})
.pipe(zip('main_files.zip'))
.pipe(gulp.dest('compiled'));
});
Ok, try:
return gulp.src(thesrc, {base: 'dist'})
For me, following did work:
// Taking everything from src and doc dirs
return gulp.src(['src/**/*', 'doc/**/*'], { base: __dirname })
.pipe(zip('dist.zip'))
.pipe(gulp.dest('dist'));