const path = require('path')
const webpack = require('webpack')

const config = {
  entry: [path.resolve(__dirname, 'src/index')],
  resolve: {
    extensions: ['.js', '.vue']
  },
  output: { path: path.resolve(__dirname, 'dist'), filename: 'bundle.js' },
  devtool: 'eval',
  module: {
    rules: [
      { enforce: 'pre', test: /\.vue$/, use: ['eslint-loader'], exclude: /node_modules/ },
      { enforce: 'pre', test: /\.js$/, use: ['eslint-loader'], exclude: /node_modules/ },
      { test: /\.vue$/, use: ['vue-loader'], exclude: /node_modules/ },
      { test: /\.js$/, use: ['babel-loader'], exclude: /node_modules/ },
      { test: /\.(glsl|frag|vert)$/, use: ['raw-loader', 'glslify-loader'], exclude: /node_modules/ }
    ]
  }
}

// NODE_ENV defaults to 'development'
if (process.env.NODE_ENV === 'production') {
  config.devtool = 'cheap-module-source-map'
  config.plugins = [
    new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production') }),
    new webpack.optimize.UglifyJsPlugin({
      sourceMap: true,
      compress: { screw_ie8: true, warnings: false },
      mangle: { screw_ie8: true },
      output: { comments: false, screw_ie8: true }
    })
  ]
} else {
  config.plugins = [new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('development') })]
}

module.exports = config

@@ -254,27 +254,8 @@
  %7D,%0A
-  devtool: 'eval',%0A
   mo
@@ -720,46 +720,8 @@
 %0A%7D%0A%0A
-// NODE_ENV defaults to 'development'%0A
 if (
@@ -960,191 +960,80 @@
 in(%7B
-%0A      sourceMap: true,%0A      compress: %7B screw_ie8: true, warnings: false %7D,%0A      mangle: %7B screw_ie8: true %7D,%0A      output: %7B comments: false, screw_ie8: true %7D%0A    %7D)%0A  %5D%0A%7D else %7B
+ compress: %7B warnings: false %7D %7D)%0A  %5D%0A%7D else %7B%0A  config.devtool = 'eval'
 %0A  c

set unused flag to false in uglify-js for uglify-js bug workaround