const { join } = require('path')
const webpack = require('webpack')
const UglifyJSWebpackPlugin = require('uglifyjs-webpack-plugin')

const productionDevtool = 'source-map'
const developmentDevtool = 'eval-source-map'

let config = {
  devtool: (process.env.NODE_ENV === 'production') ? productionDevtool : developmentDevtool,

  devServer: {
    contentBase: './',
    publicPath: 'http://localhost:8080/build/'
  },

  output: {
    path: join(__dirname, 'public', 'build'),
    filename: '[name].bundle.js'
  },

  module: {
    rules: [
      {
        test: /\.(scss)$/,
        include: join(__dirname, 'src'),
        exclude: /node_modules/,
        use: [
          {
            loader: 'style-loader'
          }, {
            loader: 'css-loader',
            options: {
              sourceMap: true
            }
          }, {
            loader: 'sass-loader',
            options: {
              sourceMap: true
            }
          }
        ]
      }, {
        test: /\.(png|gif|jpg|woff2|tff|svg)$/,
        include: join(__dirname, 'src'),
        exclude: /node_modules/,
        use: [
          {
            loader: 'url-loader'
          }
        ]
      }, {
        test: /\.(jsx|js)$/,
        include: join(__dirname, 'src'),
        exclude: /node_modules/,
        use: [
          {
            loader: 'babel-loader'
          }
        ]
      }
    ]
  },

  plugins: [],

  resolve: {
    modules: ['node_modules'],
    extensions: ['.js', '.jsx']
  }
}

if (process.env.NODE_ENV === 'production') {
  config.plugins.push(new UglifyJSWebpackPlugin({
    uglifyOptions: {
      output: {
        comments: false
      }
    }
  }))
  config.plugins.push(new webpack.DefinePlugin({
    'process.env': {
      'NODE_ENV': JSON.stringify('production')
    }
  }))
}

let appConfig = {
  target: 'electron-renderer',
  devtool: (process.env.NODE_ENV === 'production') ? productionDevtool : developmentDevtool,

  entry: {
    app: './src/bootstraps/app.jsx'
  }
}

let appletsConfig = {
  target: 'web',
  devtool: (process.env.NODE_ENV === 'production') ? productionDevtool : developmentDevtool,

  entry: {
    history: './src/bootstraps/history.jsx',
    newTab: './src/bootstraps/new-tab.jsx',
    settings: './src/bootstraps/settings.jsx'
  }
}

appConfig = Object.assign(appConfig, config)
appletsConfig = Object.assign(appletsConfig, config)

module.exports = [appConfig, appletsConfig]

@@ -1008,17 +1008,17 @@
 %7Cwoff2%7Ct
-f
+t
 f%7Csvg)$/
@@ -1541,139 +1541,8 @@
 ) %7B%0A
-  config.plugins.push(new UglifyJSWebpackPlugin(%7B%0A    uglifyOptions: %7B%0A      output: %7B%0A        comments: false%0A      %7D%0A    %7D%0A  %7D))%0A
   co
@@ -1731,90 +1731,8 @@
 tool
-: (process.env.NODE_ENV === 'production') ? productionDevtool : developmentDevtool
 ,%0A%0A 
@@ -1823,16 +1823,16 @@
  'web',%0A
+
   devtoo
@@ -1836,90 +1836,8 @@
 tool
-: (process.env.NODE_ENV === 'production') ? productionDevtool : developmentDevtool
 ,%0A%0A 

Update webpack.config.js