External source maps for minified, transpiled ES6 code with webpack and gulp

前端 未结 2 2038
孤街浪徒
孤街浪徒 2021-02-05 04:44

I\'m writing ES6 code and transpile it to ES5 with Babel, then minify with Uglify. All run with webpack via gulp. I would like to use external source maps (to keep filesize as s

2条回答
  •  遇见更好的自我
    2021-02-05 05:33

    I would recommend using webpack's devtool: 'source-map'

    Here's an example webpack.config with source mapping below:

    var path = require('path');
    var webpack = require('webpack');
    
    module.exports = {
      devtool: 'source-map',
      entry: ['./index'],
      output: {
        filename: 'bundle.js',
        path: path.join(__dirname, 'public'),
        publicPath: '/public/'
      },
      module: {
        loaders: [
          { test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/ }
        ]
      },
      plugins: [
      ]
    
    };
    

提交回复
热议问题