2
5

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

webpack v1からv2への以降作業 簡易まとめ

2
Last updated at Posted at 2017-01-23

公式に、手順書でてた。

Migrating from v1 to v2

アップデート

とりあえず、アップデート

npm install --save-dev webpack@2.2.0

修正箇所

  • debug, eslintの設定削除
  • loaders -> rules
  • preLoaders -> rules.enforce
  • loader: cssが loader: css-loaderと省略不可に
  • json-loader消した
  • DedupePlugin消した
  • resolve: {'', 'js', 'jsx'} -> resolve: {'js', 'jsx'}
diff --git a/webpack.config.babel.js b/webpack.config.babel.js
index f5cbd1a..8ae3f3a 100644
--- a/webpack.config.babel.js
+++ b/webpack.config.babel.js
@@ -1,5 +1,4 @@
 module.exports = {
   cache: true,
-  debug: true,
   devtool: 'inline-source-map',
 };
@@ -22,15 +22,12 @@ const common = {
     headers: { 'Access-Control-Allow-Origin': '*' },
   },
   module: {
-    preLoaders: [
-      { test: /\.jsx?$/, exclude: /node_modules/, loader: 'eslint' },
-    ],
-    loaders: [
-      { test: /\.jsx?$/, exclude: /node_modules/, loaders: ['react-hot-loader/webpack', 'babel'] },
-      { test: /\.css$/, loaders: ['style', 'css'] },
-      { test: /\.json/, loader: 'json' },
-      { test: /\.(eot|ttf|woff|woff2)$/, loader: 'file?name=material-design-icons/iconfont/[name].[ext]' },
-      { test: /\.(jpe?g|png|gif|svg)$/, loader: 'url?limit=10000' },
+    rules: [
+      { test: /\.jsx?$/, enforce: 'pre', exclude: /node_modules/, loader: 'eslint-loader' },
+      { test: /\.jsx?$/, exclude: /node_modules/, use: ['react-hot-loader/webpack', 'babel-loader'] },
+      { test: /\.css$/, use: ['style-loader', 'css-loader'] },
+      { test: /\.(eot|ttf|woff|woff2)$/, loader: 'file-loader?name=material-design-icons/iconfont/[name].[ext]' },
+      { test: /\.(jpe?g|png|gif|svg)$/, loader: 'url-loader?limit=10000' },
     ],
   },
   stats: {
@@ -54,10 +51,7 @@ const common = {
     }),
   ],
   resolve: {
-    extensions: ['', '.js', '.jsx'],
-  },
-  eslint: {
-    configFile: './.eslintrc',
+    extensions: ['.js', '.jsx'],
   },
 };

とりあえず、これで動いた。
プラグインまわりも変わってるので合わせて見直す必要あり。

2
5
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
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?