尽管webpack源映射,jsx反应调试器不匹配

时间:2016-03-12 23:25:56

标签: debugging reactjs google-chrome-devtools react-jsx source-maps

我正在学习React和JSX,并使用webpack进行编译,但是当我进入' debugger'在我的组件中,当我在Chrome开发工具中使用该行时,该行不匹配'来源标签(一般情况下,来源并不反映我在app.jsx文件中的内容)。 React选项卡也没有真正加载。下面是我的webpack.config:

module.exports = {
  context: __dirname,
  entry: "./api_assignment.jsx",
  output: {
    path: "./",
    filename: "bundle.js"
  },
  module: {
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        loader: 'babel',
        query: {
          presets: ['react']
        }
      }
    ]
  },
  devtool: 'source-map',
  resolve: {
    extensions: ["", ".js", ".jsx"]
  }
};

enter image description here

// Webpack截图

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:3)

如果要从本地文件而不是webpack服务器加载html,则需要启用React Developer Tools扩展选项“允许访问文件URL”。