const webpack = require('webpack')
const { execSync } = require('child_process')
const path = require('path')

let hash = execSync('git rev-parse --short HEAD').toString().trim()

let plugins = [new webpack.optimize.UglifyJsPlugin()]
let devtool = 'source-map'

if (process.env.ESP_PROD) {
  // ignore demo
  plugins.push(new webpack.IgnorePlugin(/\.\/demo(?:\.js)?$/))

  // no source maps
  devtool = ''
}

module.exports = {
  entry: './js',
  output: {
    path: path.resolve(__dirname, 'out', 'js'),
    filename: `app.${hash}.js`
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: [
          path.resolve(__dirname, 'node_modules')
        ],
        loader: 'babel-loader'
      }
    ]
  },
  devtool,
  plugins
}

@@ -192,45 +192,8 @@
  = %5B
-new webpack.optimize.UglifyJsPlugin()
 %5D%0Ale
@@ -365,16 +365,110 @@
 = ''%0A%7D%0A%0A
+plugins.push(new webpack.optimize.UglifyJsPlugin(%7B%0A  sourceMap: devtool === 'source-map'%0A%7D))%0A%0A
 module.e

Fix uglify removing source map