const path = require('path')
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')

const DEBUG = !(process.env.NODE_ENV === 'production')
const VERBOSE = process.argv.includes('--verbose')
const HOT_DEPLOY = !!process.env.HOT_DEPLOY
let CONTEXT_PATH = `${(process.env.CONTEXT_PATH || '')}`

const hotMiddlewareScript = 'webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000&reload=true'

module.exports = {
  context: __dirname + '/web/src/main/client',
  entry: {
    'js/bundle': [...(HOT_DEPLOY ? [hotMiddlewareScript] : []), './index.js']
  },
  output: {
    path: __dirname + '/web/src/main/resources/static',
    filename: 'assets/[name].js',
    publicPath: `${CONTEXT_PATH}/`
  },
  resolve: {
    extensions: ['.js', '.jsx']
  },
  devtool: DEBUG ? 'inline-source-map' : false,
  plugins: [
    new webpack.DefinePlugin({
      'process.env.CONTEXT_PATH': `"${CONTEXT_PATH}"`,
      'process.env.NODE_ENV': `"${process.env.NODE_ENV || (DEBUG ? 'development' : 'production')}"` 
    }),
    ...(HOT_DEPLOY ? [new webpack.HotModuleReplacementPlugin()] : []),
    ...(DEBUG ? [] : [new webpack.optimize.AggressiveMergingPlugin()]),
    new HtmlWebpackPlugin({
      title: 'himawari',
      template: 'index.ejs'
    }),
    new CopyWebpackPlugin([
      { from: 'assets'}
    ])
  ],
  module: {
    rules: [
      {
        test: /\.(js|jsx)$/,
        exclude: /node_modules/,
        use: ['babel-loader']
      },
      {
        test: /\.ejs$/,
        loader: 'ejs-loader'
      }
    ]
  }
}

@@ -1391,16 +1391,434 @@
 %5D)%0A  %5D,%0A
+  optimization: %7B%0A    splitChunks: %7B%0A      cacheGroups: %7B%0A        // react.js%E3%81%AB%E5%88%86%E9%9B%A2%0A        react: %7B%0A          test: /react/,%0A          name: 'react',%0A          chunks: 'all',%0A        %7D,%0A        // core.js%E3%81%AB%E5%88%86%E9%9B%A2%0A        core: %7B%0A          test: /redux%7Ccore-js%7Cjss%7Chistory%7Cmatarial-ui%7Clodash%7Cmoment%7Crollbar%7Cradium%7Cprefixer%7C%5C.io%7Cplatform%7Caxios/,%0A          name: 'core',%0A          chunks: 'all',%0A        %7D,%0A      %7D,%0A    %7D,%0A  %7D,%0A
   module

分割して出力できたのでコミット。どのライブラリを分割するかは要精査