var path = require('path')
var webpack = require('webpack')
var StaticSiteGeneratorPlugin = require('static-site-generator-webpack-plugin')
var HappyPack = require('happypack')

var isDev = process.env.NODE_ENV !== 'production'
var root  = __dirname

module.exports = {

  context: root,

  devtool: isDev ? 'inline-source-map' : 'source-map',

  entry: {
    'chatbot'      : './chatbot/client',
    'react-router' : './react-router/client',
    'simple-svg'   : './simple-svg/client',
    'painter'      : './painter/client',

    'chatbot-static'      : './chatbot/static',
    'react-router-static' : './react-router/static',
    'simple-svg-static'   : './simple-svg/static',
    'painter-static'      : './painter/static'
  },

  output: {
    filename: '[name]/main.js',
    path: path.resolve(root, '..', 'site'),
    libraryTarget: 'umd'
  },

  plugins: [
    new StaticSiteGeneratorPlugin('chatbot-static', ['chatbot' ], {}),
    new StaticSiteGeneratorPlugin('react-router-static', ['react-router' ], {}),
    new StaticSiteGeneratorPlugin('simple-svg-static', ['simple-svg' ], {}),
    new StaticSiteGeneratorPlugin('painter-static', ['painter' ], {}),

    new webpack.DefinePlugin({
      "process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV)
    }),

    new HappyPack({
      id: 'js'
    })
  ],

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

  module: {
    loaders: [
      {
        test: /\.html/,
        loader: 'mustache',
        exclude: /node_modules/,
        happy: { id: 'js' }
      },
      {
        test     : /\.jsx*$/,
        loader   : 'babel',
        exclude: /node_modules/,
        happy: { id: 'js' }
      }]
  },

  devServer: {
    contentBase : path.resolve(root, '..', 'site'),
    publicPath  : '/',
    port        : process.env.PORT || 4000,
    noInfo      : true
  }
}

// Inject the dev server hot module replacement into
// each entry point on development
if (!isDev) {
  // Otherwise enable production settings
  module.exports.plugins.push(
    new webpack.optimize.UglifyJsPlugin(),
    new webpack.optimize.OccurenceOrderPlugin()
  )
}

@@ -136,45 +136,8 @@
 in')
-%0Avar HappyPack = require('happypack')
 %0A%0Ava
@@ -1225,52 +1225,8 @@
 NV)%0A
-    %7D),%0A%0A    new HappyPack(%7B%0A      id: 'js'%0A
     
@@ -1413,37 +1413,8 @@
 les/
-,%0A        happy: %7B id: 'js' %7D
 %0A   
@@ -1520,37 +1520,8 @@
 les/
-,%0A        happy: %7B id: 'js' %7D
 %0A   

Remove HappyPack from examples webpack config