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

const pkg = require('./package.json')

const UglifyJsPlugin = webpack.optimize.UglifyJsPlugin
const env = process.env.NODE_ENV

const plugins = []
const libraryName = pkg.name
const banner = `
   ${libraryName} v${pkg.version}
   ${pkg.description}
   Copyright (c) 2016 ${pkg.author.name}
   https://github.com/${pkg.repository}
   ${pkg.license} license
`

let outputFile

if (env === 'build') {
  plugins.push(new UglifyJsPlugin({ minimize: true }))
  plugins.push(new webpack.BannerPlugin(banner))

  outputFile = `${libraryName}.min.js`
} else {
  outputFile = `${libraryName}.js`
}

module.exports = {
  entry: path.join(__dirname, `/src/${libraryName}`),
  devtool: 'source-map',
  output: {
    path: path.join(__dirname, '/dist'),
    filename: outputFile,
    library: libraryName,
    libraryTarget: 'umd',
    umdNamedDefine: true
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        loader: 'babel',
        exclude: /node_modules/
      }
    ]
  },
  plugins,
  resolve: {
    root: path.resolve('./src'),
    extensions: ['', '.js']
  }
}

@@ -101,63 +101,8 @@
 ')%0A%0A
-const UglifyJsPlugin = webpack.optimize.UglifyJsPlugin%0A
 cons
@@ -273,12 +273,35 @@
 (c) 
-2016
+$%7Bnew Date().getFullYear()%7D
  $%7Bp
@@ -401,16 +401,64 @@
 utFile%0A%0A
+plugins.push(new webpack.BannerPlugin(banner))%0A%0A
 if (env 
@@ -491,16 +491,33 @@
 ush(new 
+webpack.optimize.
 UglifyJs
@@ -548,58 +548,8 @@
 %7D))%0A
-  plugins.push(new webpack.BannerPlugin(banner))%0A%0A
   ou

Update Webpack config