import path from 'path'
import webpack from 'webpack'

import config from './config.js'
import webpackConfig from './webpack.config.babel.js'
import pkg from '../package.json'

// ! client side loader only \\
export default {
  ...webpackConfig,
  module: {
    ...webpackConfig.module,
    loaders: [
      ...webpackConfig.module.loaders,
      {
        test: /\.json$/,
        loader: 'json-loader'
      },
      {
        test: /\.js$/,
        loaders: [
          'babel-loader?' +
          // hack for babel config to undo babel-plugin-webpack-loaders effect
          JSON.stringify({
            ...pkg.babel,
            plugins: [
              ...pkg.babel.plugins && pkg.babel.plugins,
              ...config.production && [
                'transform-react-remove-prop-types',
                'babel-plugin-lodash'
              ]
            ],
            // add hot loading/error reporting for development
            presets: [
              ...pkg.babel.presets,
              ...config.dev && [ 'babel-preset-react-hmre' ]
            ],
            // forget 'statinamic' env
            env: { ...pkg.babel.env, 'statinamic': undefined },
            // prevent babel going to use your original config
            babelrc: false
          })
          // 'eslint-loader?fix'
        ],
        exclude: /node_modules/
      }
    ]
  },
  plugins: [
    ...webpackConfig.plugins,
    new webpack.optimize.CommonsChunkPlugin({
      names: ['w-1-vendor', 'manifest']
    })
  ],
  // ↓ HANDLE WITH CARE ↓ \\

  output: {
    ...webpackConfig.output,
    libraryTarget: 'var',
    filename: '[name].[hash].js',
    ...config.production && {
      filename: '[name].[chunkhash].js'
    }
  },
  entry: {
    'w-1-vendor': [
      'react',
      'react-redux',
      'react-helmet',
      'react-router',
      'redux',
      'whatwg-fetch',
      'moment',
      'classnames'
    ],
    'w-2-client': path.join(__dirname, 'index-client')
  }
}

@@ -20,38 +20,8 @@
 ath'
-%0Aimport webpack from 'webpack'
 %0A%0Aim
@@ -1331,149 +1331,8 @@
  %7D,%0A
-  plugins: %5B%0A    ...webpackConfig.plugins,%0A    new webpack.optimize.CommonsChunkPlugin(%7B%0A      names: %5B'w-1-vendor', 'manifest'%5D%0A    %7D)%0A  %5D,%0A
   //
@@ -1356,16 +1356,16 @@
 RE %E2%86%93 %5C%5C%0A
+
 %0A  outpu
@@ -1549,24 +1549,27 @@
 entry: %7B%0A   
+ //
  'w-1-vendor
@@ -1572,24 +1572,27 @@
 ndor': %5B%0A   
+ //
    'react',%0A
@@ -1587,34 +1587,37 @@
    'react',%0A    
+//
   
+ 
 'react-redux',%0A 
@@ -1614,24 +1614,27 @@
 -redux',%0A   
+ //
    'react-he
@@ -1639,24 +1639,27 @@
 helmet',%0A   
+ //
    'react-ro
@@ -1664,24 +1664,27 @@
 router',%0A   
+ //
    'redux',%0A
@@ -1682,24 +1682,27 @@
 'redux',%0A   
+ //
    'whatwg-f
@@ -1712,18 +1712,21 @@
 h',%0A    
+//
   
+ 
 'moment'
@@ -1730,16 +1730,19 @@
 nt',%0A   
+ //
    'clas
@@ -1752,16 +1752,19 @@
 mes'%0A   
+ //
  %5D,%0A    

Remove vendor spliting