webpack 1.x から 3.x へ移行する作業をした際のメモ。
npm モジュールのアップデート
webpack v1 から webpack v3 へ移行 | WOWブログ を参考に。
$ npm install -g npm-check-updatesアップデートのチェック
$ ncu
Using /path/to/project/package.json
⸨░░░░░░░░░░░░░░░░░░⸩ ⠸ :
copy-webpack-plugin ^2.1.1 → ^4.3.0
css-loader ^0.23.1 → ^0.28.7
file-loader ^0.8.5 → ^1.1.6
imports-loader ^0.6.5 → ^0.7.1
jquery ^2.2.3 → ^3.2.1
store ^1.3.20 → ^2.0.12
style-loader ^0.13.1 → ^0.19.1
url-loader ^0.5.7 → ^0.6.2
webpack ^1.13.0 → ^3.10.0
The following dependencies are satisfied by their declared version range, but the installed versions are behind. You can install the latest versions without modifying your package file by using npm update. If you want to update the dependencies in your package file anyway, run ncu -a.
clean-webpack-plugin ^0.1.8 → ^0.1.17
assets-webpack-plugin ^3.4.0 → ^3.5.1
expose-loader ^0.7.1 → ^0.7.4
featherlight ^1.4.0 → ^1.7.12
jquery-textcomplete ^1.3.4 → ^1.8.4
knockout ^3.4.0 → ^3.4.2
flowchart.js ^1.6.4 → ^1.7.0
Run ncu with -u to upgrade package.jsonThe following dependencies are satisfied by... 以下に記載されているライブラリは、
最新ではないものの依存解決を満たすバージョン範囲内ではあるということ。
package.json を更新
ncu -u で package.json が更新される(npm update はされない)
上記 ncu チェックで The following dependencies are satisfied by... 以下に記載されているライブラリは対象外。
$ ncu -uncu -a だと The following dependencies are satisfied by... 以下に記載されているライブラリも対象になる。
$ ncu -anpm update
npm-check-updates は package.json を書き換えるまで。
実際のアップデートは通常どおり npm update で行う。
トラブルを避けるため node_modules ディレクトリを消してから、npm install するのがオススメ。
webpack
公式のマイグレーションガイド: Migrating Versions
resolve.modulesDirectories→resolve.modulesmodule.loaders→module.rules- loader 系は全て
-loaderサフィックスをつけるcss!...→css-loader!...など