google-chrome - 使用 webpack-2 在 Chrome 中检测到源映射但未加载原始源

标签 google-chrome webpack source-maps webpack-2

运行使用 webpack 2 构建的应用程序时,在 chrome 中检测到源映射,但未加载原始源。
我正在使用 webpack beta21。

这些文件过去是自动检测的,即当在 webpack js 文件的输出中放置断点时,源 View 会跳转到 webpack 的原始源输入。但现在我被这个屏幕困住了:
enter image description here

配置:

var path = require("path");
var webpack = require("webpack");
var WebpackBuildNotifierPlugin = require('webpack-build-notifier');


const PATHS = {
  app: path.join(__dirname, '../client'),
  build: path.join(__dirname, '../public')
};

module.exports = {


  entry: {
    app: PATHS.app + '/app.js'
  },
  output: {
    path: PATHS.build,
    filename: '[name].js'
  },


  devtool: "source-map",
  module: {
    loaders: [
      {
        test: /\.js?$/,
        loader: 'babel-loader',
        include: [
          path.resolve(__dirname, 'client'),
        ],
        exclude: /node_modules/

      },

      {
        test: /\.css/,
        loader: "style!css"
      }
    ]
  },
  resolve: {
    // you can now require('file') instead of require('file.js')
    extensions: ['', '.js', '.json']
  } ,
  plugins: [
    new WebpackBuildNotifierPlugin()
  ]

};

最佳答案

带有源映射的生成文件不会自动重定向到其原始文件,因为可能存在一对多关系。
如果您看到消息 Source Map Detected ,原始文件应该已经通过Crl + P出现在侧文件树或文件资源管理器中。 如果您不知道原始文件名,可以打开源映射文件本身。

  • 源映射路径可以由 //# sourceMappingURL= 标识评论或 X-SourceMap标题:
    sourceMappingURL
  • 通过 url 打开源映射并查找 sources原始文件名的属性:
    source map file
  • 原始文件应该在源面板中可见:
    original file in sources panel

  • 如果您没有看到消息 Source Map Detected您可以通过右键单击并选择 Add Source Map 来手动添加外部源映射。 :
    Add source map
    其他资源
  • 如果还是不行,你可以试试 Source Map Validator
  • 对于 webpack,你可以配置 devtool 属性(property)
  • 关于google-chrome - 使用 webpack-2 在 Chrome 中检测到源映射但未加载原始源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39146381/

    相关文章:

    javascript - 如何在 DOM 中显示 source map 的 JS 错误

    typescript - 在 Chrome DevTools 中看不到 ES6 和 TypeScript 库的源代码

    GWT SuperDevMode 抛出这个 : Multiple fragment 0 sourcemaps found. Too many permutations

    javascript - Chrome 扩展 - 单击实际页面中的元素

    django - Chrome 上未设置第三方 cookie(Django 应用程序)

    laravel mix 从 node_modules 中的包编译 Assets ​​?

    node.js - 防止在监视模式下运行时对某些文件夹进行更改后自动重新启动服务器

    html - 新 Ghost 博客上的链接仅在 Chrome 中不起作用的问题

    html - 在 headless print-to-pdf 中禁用 Chrome 的默认页眉和页脚

    正则表达式从 node_modules 中排除文件夹