0
0

More than 1 year has passed since last update.

rollupjsのwatchのAPI実行で、変更検知が動かない

Last updated at Posted at 2022-10-01

1.背景と現象

  • rollupjsをAPIとして、つまり、JavaScript内でモジュールとして呼び出して実行している。
  • コマンドラインからの実行ではない。
  • ある時からwatchを実行しても、変更を検知して処理が再実行されなくなった。

2.対応

以下のようwatchのオプションにあるchokidar.usePollingを設定すると変更を検知するようになった。

const rollup = require("rollup");

//オプション
const option = {
    input: "ビルド対象の起点ファイルパス",
    output: [
		file: "バンドルしたファイルのパス",
		format: "iife"
    ],
    watch: {
      chokidar: {
          usePolling: true
      },
    },
};

//watch実行
rollup.watch(option).on("event", (event) => {
//ビルド実行イベント処理
});

この中で以下の部分がないと変更を検知しなかった。

    watch: {
      chokidar: {
          usePolling: true
      },
    },

※以下のサイトがとても参考になりました。

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