微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

reactjs – React Webpack – 错误:模块不是加载器(必须具有正常或音调功能)

我的webpack.config.js
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)

看起来有些人通过为模块添加-loader扩展来工作(https://github.com/webpack/webpack/issues/3180),但对我来说它仍然无法解决.

请协助.

我认为用法是react-hot-loader / webpack
loaders: ['react-hot-loader/webpack',

在这里查看一些示例用法http://gaearon.github.io/react-hot-loader/getstarted/

原文地址:https://www.jb51.cc/react/300961.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐