LoginSignup
1
0

More than 3 years have passed since last update.

WebPack-DevServerのバグの対応

Posted at

詳しいことはよくわからないがDevServerでホットリロードできなくなる問題がある模様

解決法

configのtargetをwebに書き換える

webpack.config.js

module.exports={
...
target:"web" //ふつうは["web","es5"]とかかな?
...
}

けどこの方法だと、ビルドするときに戻さないといけなくなる

解決法改

ドキュメントによると
オブジェクトの代わりに関数をエクスポートすると、実行時のモードによって
動作を変更できるらしい

webpack.config.js
const config ={
...
}
module.exports = (env, argv) => {
  if (argv.mode !== 'production') {
    config.target = 'web';
  }
  return config;
};

これでおそらくは大丈夫と思う

1
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
1
0