5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

gulp-zipでディレクトリ構成を保ったまま圧縮する

Posted at

gulpを使って圧縮ファイルを作りたい時に、ディレクトリ構成を保ったまま圧縮する方法

ライブラリは gulp-zip を使用。

Usage通りに gulp.src('src/*') と指定するとルートディレクトリに全部展開されてしまう。
gulp.src('src/**/*', {base: 'src'}) と、 base を追加すると指定されたディレクトリの構成を保ったまま圧縮できる。

basegulp自体の機能 なので、他でも使えるテクニックだった。

全体

const gulp = require('gulp');
const zip = require('gulp-zip');
 
gulp.task('default', () => {
	return gulp.src('src/*', {base: 'src'})
		.pipe(zip('archive.zip'))
		.pipe(gulp.dest('dist'));
});
5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?