質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.46%
gulp

gulpは、Node.jsをベースとしたタスク自動化ツールの一つ。ストリームでファイルを処理することが特徴です。CSSプリプロセッサの使用時のコンパイルや、CSS・JavaScriptファイルの圧縮・結合などを自動的に行うことができます。

Q&A

解決済

1回答

869閲覧

Gulpでwatch関数実行後finishしない

KengoShimizu

総合スコア6

gulp

gulpは、Node.jsをベースとしたタスク自動化ツールの一つ。ストリームでファイルを処理することが特徴です。CSSプリプロセッサの使用時のコンパイルや、CSS・JavaScriptファイルの圧縮・結合などを自動的に行うことができます。

0グッド

0クリップ

投稿2020/02/16 13:01

前提・実現したいこと

Gulpを実行すると,うまくコンパイルはしてくれるが,正常にfinishしてくれない.

ソースコード
// パッケージをインストール import gulp from 'gulp'; import notify from 'gulp-notify'; import plumber from 'gulp-plumber'; import pug from 'gulp-pug'; import sass from 'gulp-sass'; import typescript from 'gulp-typescript'; //pug入力先、html出力先を記述 const paths = { src: { pug: "src/index.pug", scss: "src/scss/index.scss", ts: ["src/ts/index.ts"], }, public: { html: "public/", css: "public/css/", js: "public/js/", }, }; const pugOptions = { pretty: true, }; // pugコンパイル function conpilePug() { gulp.src(paths.src.pug) .pipe(plumber(notify.onError('Error: <%= error.message %>'))) .pipe(pug(pugOptions)) .pipe(gulp.dest(paths.public.html)); } // scssコンパイル function conpileScss() { gulp.src(paths.src.scss) .pipe(plumber(notify.onError('Error: <%= error.message %>'))) .pipe(sass(pugOptions)) .pipe(gulp.dest(paths.public.css)); } // typescriptコンパイル function conpileTypescript() { gulp.src(paths.src.ts) .pipe(plumber(notify.onError('Error: <%= error.message %>'))) .pipe(typescript({ target: "ES5", removeComments: true, sortOutput: true })) .pipe(gulp.dest(paths.public.js)); } gulp.task("default", function(){ gulp.watch(paths.src.pug, conpilePug()); gulp.watch(paths.src.scss, conpileScss()); gulp.watch(paths.src.ts, conpileTypescript()); });

発生している問題・エラーメッセージ

yarn run v1.21.1 $ /Library/WebServer/Documents/helloworld/node_modules/.bin/gulp [21:47:18] Requiring external module babel-register [21:47:18] Using gulpfile /Library/WebServer/Documents/helloworld/gulpfile.babel.js [21:47:18] Starting 'default'... gulp-typescript: sortOutput is deprecated - your project might work without it The non-standard option sortOutput has been removed as of gulp-typescript 3.0. Your project will probably compile without this option. Otherwise, if you're using gulp-concat, you should remove gulp-concat and use the outFile option instead. More information: http://dev.ivogabe.com/gulp-typescript-3/ [21:47:18] Finished 'default' after 14 ms src/ts/index.ts(2,12): error TS2370: A rest parameter must be of an array type. : : TypeScript: 16 semantic errors TypeScript: emit succeeded (with errors) [21:47:19] gulp-notify: [Error running Gulp] Error: TypeScript: Compilation failed ^C

わからないこと

こちらのソースコードはES6で記述しており,Babelを使用してES5への下位互換を適応して実行しております.
ネット上で調べながら書いてみたのですが,正常に実行が完了すると以下のスクリプトが帰ってきてプログラムが終了するはずなのですが,こちらの実行結果ではctr+Cを入力するまでプログラムが終了することはありません.(コンパイルは上手くできています)
どうすれば解決できるかわかりません.助言をいただけますか.お願いします.

Finished 'default' after 6.15 ms

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

gulp などの watch というのは、ソースファイルの更新状況を監視して、更新されたら自動的にビルドし直して、場合によってはブラウザの表示も更新してくれるもので、ずっと走らせておいて別のエディタで開発を進める、という使い方をします。ので、finish しないのが正常だと思います。

投稿2020/02/18 01:30

hoshi-takanori

総合スコア7895

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.46%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問