2017-06-20 7 views
4

マイwebpack.config.jsはWebPACKのに反応 - エラー:モジュールローダではありません(正常またはピッチの機能を持っている必要があります)

var path = require("path") 
var webpack = require('webpack') 
var BundleTracker = require('webpack-bundle-tracker') 

module.exports = { 
    context: __dirname, 

    entry: [ 
     'webpack-dev-server/client?http://localhost:3000', 
     'webpack/hot/only-dev-server', 
     './assets/js/index', // entry point of our app. assets/js/index.js should require other js modules and dependencies it needs 
    ], 

    output: { 
     path: path.resolve('./assets/bundles/'), 
     filename: "[name]-[hash].js", 
     publicPath: 'http://localhost:3000/assets/bundles/', // Tell django to use this URL to load packages and not use STATIC_URL + bundle_name 
    }, 

    plugins: [ 
     new webpack.HotModuleReplacementPlugin(), 
     new webpack.NoEmitOnErrorsPlugin(), // don't reload if there is an error 
     new BundleTracker({filename: './webpack-stats.json'}), 
    ], 

    module: { 
     loaders: [ 
      { 
       test: /\.jsx?$/, 
       exclude: /node_modules/, 
       loaders: ['react-hot-loader', 'babel-loader?presets[]=react'], 
      }, // to transform JSX into JS 
     ], 
    }, 

    resolve: { 
     modules: ['node_modules', 'bower_components'], 
     extensions: ['.js', '.jsx'] 
    }, 
} 

エラー:一部が動作してしまったよう

Error: Module 'C:\Workspace\PyCharmProjects\ProjectPearl\node_modules\react-hot-loader\index.js' is not a loader (must have normal or pitch function)

が見える(https://github.com/webpack/webpack/issues/3180 ) - モジュールのためのローダ拡張を追加することによって、私のためにそれはまだ解決しません。

助けてください。

答えて

15

私は使用量がreact-hot-loader/webpack

loaders: ['react-hot-loader/webpack', 'babel-loader?presets[]=react'], 

いくつかの例の使用法ここではhttp://gaearon.github.io/react-hot-loader/getstarted/

+1

そして場合には、人々がES6を使用しているを見て、同じエラーを取得し、その[移行ガイド](httpsの注意だと思います。 //github.com/gaearon/react-hot-loader/tree/master/docs#migration-to-30)は、最初のステップとして読み取ります:BabelとES6を使用している場合は、**反応ホットローダーを削除しますあなたのWebpack設定**内の任意のローダー、および.babelrcのプラグインセクションにreact-hot-loader/babelを追加してください: –

関連する問題