javascript - 无法让 webpack-dev-server (webpack) 在 Chrome 开发工具中生成源映射

标签 javascript google-chrome webpack webpack-dev-server

这在过去使用手动 webpack 对我有用,但现在对于任何反应项目,无论我使用什么配置,我似乎都无法使用 webpack-dev-server 在开发工具中获得源映射。我尝试了几个 devtools 值,包括“source-map”。我只看到“将文件添加到工作区”而不是“检测到源映射”——有什么想法吗?

chrome 版本 53.0.2785.143(64 位)(mac)

  • 开发者工具实验标志已启用

    • enter image description here

webpack 版本 1.13.2 webpack.config.js

/* eslint-disable */
const path = require('path');
var webpack = require('webpack');

module.exports = {
  devtool: 'inline-source-map', 
  entry: './app.js',
  output: {
    path: path.join(__dirname, 'dist'),
    filename: 'bundle.js'
  },
  module: {
    loaders: [{
      test: /\.js$/,
      loader: 'babel',
      exclude: /node_modules/,
      include: __dirname
    }]
  },
}

dev tools - no sourcemap

最佳答案

终于弄明白了 - 事实证明这是一个 babel 加载器配置问题。将查询参数添加到 babel 加载程序 block 允许我生成源映射:

/* eslint-disable */
const path = require('path');
var webpack = require('webpack');

module.exports = {
  devtool: 'source-map',
  entry: './app.js',
  output: {
    path: path.join(__dirname, 'dist'),
    filename: 'bundle.js'
  },
  module: {
    loaders: [{
      test: /\.js$/,
      loader: 'babel',
      exclude: /node_modules/,
      include: __dirname,
      //here
      query: {
        retainLines: true,
        cacheDirectory: true
      }
    }]
  },
}

关于javascript - 无法让 webpack-dev-server (webpack) 在 Chrome 开发工具中生成源映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40010882/

相关文章:

node.js - webpack编码问题加上webpackJsonp未定义

javascript - 使用 Express Handbars 为简单的 Node Web 应用程序传递数据

javascript - 将条形图添加到 nvd3 中 scatterChart 的工具提示中 - react 组件未渲染

JavaScript 使用 async/await 确保我在实现之前检索值,但仍然返回 'undefined'

javascript - .wheel 事件 |由于目标被视为被动,因此无法阻止被动事件监听器内的默认行为

java - 找不到要发送 Tab 键的 HTML 元素

google-chrome - 有没有办法从 Chrome 开发者工具中导出时间图?

javascript - 如何在 Browserify 和 Javascript 中进行命名空间

reactjs - 使用 Post 方法提交表单不适用于 PWA 中的 target _blank

laravel - 如何在 Laravel MIX 上创建 svg Sprite ?