Target Only The Contents Of A Folder In Gulp
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/**/
Solution 1:
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'));
});
Solution 2:
Solution 3:
For me, following did work:
// Taking everything from src and doc dirsreturn gulp.src(['src/**/*', 'doc/**/*'], { base: __dirname })
.pipe(zip('dist.zip'))
.pipe(gulp.dest('dist'));
Post a Comment for "Target Only The Contents Of A Folder In Gulp"