【问题标题】:Breakpoints in files in chrome not being hit when using webpack sourcemaps使用 webpack 源映射时,chrome 文件中的断点不会被命中
【发布时间】:2016-02-25 20:10:34
【问题描述】:

我在源 .js 文件(通过源映射加载)中有一个断点,当我在源选项卡中使用 chrome 开发工具指向时,它没有被命中。有时,如果我单击格式按钮 {},我可以让它们被击中,但它的命中和未命中。

有什么想法吗?

  "devDependencies": {
    "autoprefixer-loader": "^3.1.0",
    "babel-core": "^6.1.20",
    "babel-loader": "^6.1.0",
    "babel-preset-es2015": "^6.1.18",
    "babel-preset-stage-1": "^6.3.13",
    "css-loader": "^0.23.1",
    "material-ui": "^0.14.0",
    "style-loader": "^0.13.0",
    "stylus-loader": "^1.5.1",
    "tape": "^4.2.2",
    "webpack": "^1.12.12",
    "webpack-dev-server": "^1.12.1"
  },
  "dependencies": {
    "babel-polyfill": "^6.1.19",
    "moment": "^2.11.2",
    "normalize.css": "^3.0.3"
  }

webapck:

module.exports = {
  entry: [
    'babel-polyfill',
    './app/app.js'
  ],
  output: {
    publicPath: '/',
    filename: 'dist/main.js'
  },
  debug: true,
  devtool: 'source-map',
  module: {
    loaders: [
      {
        test: /\.js$/,
        include: path.join(__dirname, 'app'),
        loader: 'babel',
        query: {
          presets: ['es2015']
        }
      },
      { test: /\.styl$/, loader: 'style-loader!css-loader!stylus-loader' },
      { test: /\.css$/, loader: 'style-loader!css-loader' }

    ]
  },
  resolve: {
    extensions: ["", ".webpack.js", ".web.js", ".js", ".css",".styl"]
  }
};

【问题讨论】:

标签: google-chrome webpack breakpoints


【解决方案1】:

所以这似乎是issue with webpack and chrome in the past that was brought up

临时解决方案是将devtool 选项设置为source-mapinline-source-map 但请注意,这会导致编译时间增加。

从 Webpack 3 开始,该问题得到了改善,但问题在于 Chrome 和 Webpack 之间的相互作用以及它们不断变化的代码库。

使用 Webpack 3,我已经成功完成了以下配置:

devtool: 'cheap-module-source-map'

【讨论】:

    【解决方案2】:

    评论开发工具

    //devtool: 'source-map',
    

    添加到插件

    new webpack.SourceMapDevToolPlugin({
            filename: '[file].map',
            include: ['app.js'],
            exclude: ['vendor.js'],
            columns: false
        })
    

    【讨论】:

    • 您能否详细说明它的作用或原因?
    • 如果我正确理解了问题是什么,chrome 在某些情况下无法设置断点,列(默认为 true)当忽略 SorceMaps 中的错误列映射并且更快的 SourceMap 实现时用过。
    • 列可以是set to false,使用devtool: 'cheap-source-map'
    • 对我来说,这似乎与devtool: 'cheap-module-source-map'的结果相同
    • 你怎么知道的?在官方文档中没有任何关于注释掉devtool 并使用插件代替。
    猜你喜欢
    • 2020-05-14
    • 2015-11-05
    • 2016-09-04
    • 1970-01-01
    • 2016-04-02
    • 1970-01-01
    • 2019-11-05
    • 1970-01-01
    • 2013-11-29
    相关资源
    最近更新 更多