0
0

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の設定

0
Last updated at Posted at 2021-05-12

やりたいこと

作業用フォルダから本番用フォルダにファイルを出力するだけの設定メモ。

mapファイルだけ追加で生成する。

簡単に書くと以下のようなイメージ。

作業用フォルダ

  • src
    • js
      • script.js

本番用フォルダ

  • dest
    • js
      • script.js
      • script.js.map

Gulp ソースコード

Gulp 4ならオプションでsourcemapsを生成できるので以下のように書ける。
よって、gulpだけインストールしていればよい。
※Gulp 3ならgulp-sourcemapsのインストールも必要になる。

gulpfile.js
const gulp = require('gulp');

// 【例】jsをsrcディレクトリからdestディレクトリに出力するだけのタスク
gulp.task('js', function () {
	return gulp
		.src('./src/js/*.js', { sourcemaps: true })
		.pipe(gulp.dest('./dest/js/', { sourcemaps: './' }));
});

// watchタスク
gulp.task('watch', function () {
	gulp.watch('./src/js/*.js', gulp.task('js'));
});

// defaultタスク
gulp.task('default', ['watch']);
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?