如何在Webpack配置中添加调试功能

3

我已经将我的一个项目从browserify迁移到webpack,现在我想知道如何在配置文件中添加debug,类似于browserify --debug以提供源映射。

这是我的webpack.config文件:

module.exports = {
  entry: './src/js/main.js',
  output: {
    filename: 'bundle.js',
    path: './src/public/',
    publicPath: 'public'
  },
  module: {
    loaders: [
      { test: /\.js$/, loader: 'babel-loader' }
    ]
  }
};

1
将以下内容翻译成中文:将此添加到您的配置文件中 devtool: 'sourcemap' - Jesús Quintana
1
谢谢Jesús,我在文档中找到了它。 - svnm
2个回答

3

看起来我只需要添加源映射:devtool: 'source-map'

module.exports = {
  devtool: 'source-map',
  entry: './src/js/main.js',
  output: {
    filename: 'bundle.js',
    path: './src/public/',
    publicPath: 'public'
  },
  module: {
    loaders: [
      { test: /\.js$/, loader: 'babel-loader' }
    ]
  }
};

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接