前記事に引き続きですが、pwa のサンプル作成中に以下のエラーが発生しました。


エラー内容

React Hot Loader: It appears that "react-hot-loader/patch" did not run immediately before the app started. Make sure that it runs before any other code. For example, if you use Webpack, you can add "react-hot-loader/patch" as the very first item to the "entry" array in its config. Alternatively, you can add require("react-hot-loader/patch") as the very first line in the application code, before any other imports.


原因

メッセージの内容の通りですが、エントリポイントに react-hot-loader/patch記載がないか、
しくは、使用している JavaScript に require("react-hot-loader/patch")記載がないため発生するエラーです。


対応

webpack.config.js エントリポイントに以下の記述を追加しました。

    /* エントリポイント */
    entry: [
        'react-hot-loader/patch', // 追記
        './assets/js/vendor',
        './assets/js/index'],

以上です。

コメント