2
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 3 years have passed since last update.

【Webpack】開発モードと本番モード

Posted at

指定なしだとデフォルトの本番モードで処理される。
webpack.config.js で、開発モードをデフォルトにしておく。

webpack.config.js
module.exports = {
  mode: 'development',
  // 続く

package.json の "script" を以下の通り設定しておく

package.json
  "scripts": {
    "build": "webpack",
    "build-production": "webpack --mode=production"
  },

開発モードと本番モード、適用したい方で webpack を実行できる。
package.json があるディレクトリで以下コマンド

  • 開発モード npm run build
  • 本番モード npm run build-production

メモ

mode を設定せず、package.json でのコマンドを以下にしても全く同じで何ら支障はない

package.json
  "scripts": {
    "build": "webpack --mode=development",
    "build-production": "webpack --mode=production"
  },

参考記事

* [Mode | webpack](https://webpack.js.org/configuration/mode/)
2
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
2
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?