babelとwebpackを使用するときにソースマップを生成するにはどうすればいいですか? 質問する

babelとwebpackを使用するときにソースマップを生成するにはどうすればいいですか? 質問する

ソースマップを生成するための設定をしたいです。webpack serveコマンドラインから実行していますが、コンパイルは成功しています。しかし、本当にソースマップが必要なのです。これが私のですwebpack.config.js

var webpack = require('webpack');

module.exports = {

  output: {
    filename: 'main.js',
    publicPath: '/assets/'
  },

  cache: true,
  debug: true,
  devtool: true,
  entry: [
      'webpack/hot/only-dev-server',
      './src/components/main.js'
  ],

  stats: {
    colors: true,
    reasons: true
  },

  resolve: {
    extensions: ['', '.js', '.jsx'],
    alias: {
      'styles': __dirname + '/src/styles',
      'mixins': __dirname + '/src/mixins',
      'components': __dirname + '/src/components/',
      'stores': __dirname + '/src/stores/',
      'actions': __dirname + '/src/actions/'
    }
  },
  module: {
    preLoaders: [{
      test: /\.(js|jsx)$/,
      exclude: /node_modules/,
      loader: 'jsxhint'
    }],
    loaders: [{
      test: /\.(js|jsx)$/,
      exclude: /node_modules/,
      loader: 'react-hot!babel-loader'
    }, {
      test: /\.sass/,
      loader: 'style-loader!css-loader!sass-loader?outputStyle=expanded&indentedSyntax'
    }, {
      test: /\.scss/,
      loader: 'style-loader!css!sass'
    }, {
      test: /\.(png|jpg|woff|woff2)$/,
      loader: 'url-loader?limit=8192'
    }]
  },

  plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoErrorsPlugin()
  ]
};

この問題が具体的に何に当てはまるのかわからないので、ドキュメントを見てもあまり役に立ちませんでした。

ベストアンサー1

ソースマップを使用するには、変更する必要がありますdevtoolオプション値は、から利用可能なtrueまでthis list、 例えばsource-map

devtool: 'source-map'

devtool: 'source-map'- SourceMap が発行されます。

おすすめ記事