Target only the contents of a folder in gulp

gulp, javascript

Solution

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'));
});

Problem

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 - file.js However, I want it like this: - file.css - another.js - folder - file.js Without the dist folder. Is there a way to do this using a different src path? Thanks for your help.

Original source