Answer the question
In order to leave comments, you need to log in
How to set correct file and folder structure with gulp-zip?
I want to create a task that collects source files into an archive, but at the same time ignores the node_modules and packages folders. To do this, I connected the gulp-zip plugin.
I tried two approaches, but neither one is completely satisfied.
First option:
gulp.task('zip', function() {
gulp.src(['**/*.*', '!packages/**/*', '!node_modules/**/*'])
.pipe(zip(packageinfo.name + '.zip'))
.pipe(gulp.dest(baseFolder.build));
});
gulp.task('zip', function() {
gulp.src(['*.*', 'src/**/*'])
.pipe(zip(packageinfo.name + '.zip'))
.pipe(gulp.dest(baseFolder.build));
});
Answer the question
In order to leave comments, you need to log in
You need to add options.base
By default, this is everything up to * in the path, you need to specify it directly:
gulp.task('zip', function() {
gulp.src(['*.*', 'src/**/*'], {base: './'})
.pipe(zip(packageinfo.name + '.zip'))
.pipe(gulp.dest(baseFolder.build));
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question