var baseConfig = require('./webpackBaseConfig');
var webpack = require('webpack');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = Object.assign({}, baseConfig, {
    plugins: [
        new webpack.ProvidePlugin({
            Visibility: "visibilityjs",
            Cookies: "js-cookie",
            key: "keymaster",
            $: "jquery",
            jQuery: "jquery",
            "window.jQuery": "jquery",
            "moment": "moment",
            "Handlebars": "handlebars"
        }),
        new ExtractTextPlugin("[name].css"),
        new webpack.optimize.CommonsChunkPlugin({
            names: ["cover", "index", "pretty", "slide", "vendor"],
            children: true,
            async: true,
            filename: '[name].js',
            minChunks: Infinity
        }),
        new HtmlWebpackPlugin({
            template: 'public/views/includes/header.ejs',
            chunks: ['vendor', 'index'],
            filename: path.join(__dirname, 'public/views/build/index-header.ejs'),
            inject: false
        }),
        new HtmlWebpackPlugin({
            template: 'public/views/includes/scripts.ejs',
            chunks: ['vendor', 'index'],
            filename: path.join(__dirname, 'public/views/build/index-scripts.ejs'),
            inject: false
        }),
        new HtmlWebpackPlugin({
            template: 'public/views/includes/header.ejs',
            chunks: ['vendor', 'cover'],
            filename: path.join(__dirname, 'public/views/build/cover-header.ejs'),
            inject: false
        }),
        new HtmlWebpackPlugin({
            template: 'public/views/includes/scripts.ejs',
            chunks: ['vendor', 'cover'],
            filename: path.join(__dirname, 'public/views/build/cover-scripts.ejs'),
            inject: false
        }),
        new HtmlWebpackPlugin({
            template: 'public/views/includes/header.ejs',
            chunks: ['vendor', 'pretty'],
            filename: path.join(__dirname, 'public/views/build/pretty-header.ejs'),
            inject: false
        }),
        new HtmlWebpackPlugin({
            template: 'public/views/includes/scripts.ejs',
            chunks: ['vendor', 'pretty'],
            filename: path.join(__dirname, 'public/views/build/pretty-scripts.ejs'),
            inject: false
        }),
        new HtmlWebpackPlugin({
            template: 'public/views/includes/header.ejs',
            chunks: ['vendor', 'slide'],
            filename: path.join(__dirname, 'public/views/build/slide-header.ejs'),
            inject: false
        }),
        new HtmlWebpackPlugin({
            template: 'public/views/includes/scripts.ejs',
            chunks: ['vendor', 'slide'],
            filename: path.join(__dirname, 'public/views/build/slide-scripts.ejs'),
            inject: false
        }),
        new webpack.DefinePlugin({
            'process.env': {
                'NODE_ENV': JSON.stringify('production')
            }
        }),
        new webpack.optimize.UglifyJsPlugin({
            compress: {
                warnings: false
            },
            mangle: false,
            sourceMap: false
        })
    ],

    output: {
        path: path.join(__dirname, 'public/build'),
        publicPath: '/build/',
        filename: '[id].[name].[hash].js'
    },
});

@@ -84,2856 +84,122 @@
 var 
-ExtractTextPlugin = require(%22extract-text-webpack-plugin%22);%0Avar path = require('path');%0Avar HtmlWebpackPlugin = require('html-webpack-plugin');%0A%0Amodule.exports = Object.assign(%7B%7D, baseConfig, %7B%0A    plugins: %5B%0A        new webpack.ProvidePlugin(%7B%0A            Visibility: %22visibilityjs%22,%0A            Cookies: %22js-cookie%22,%0A            key: %22keymaster%22,%0A            $: %22jquery%22,%0A            jQuery: %22jquery%22,%0A            %22window.jQuery%22: %22jquery%22,%0A            %22moment%22: %22moment%22,%0A            %22Handlebars%22: %22handlebars%22%0A        %7D),%0A        new ExtractTextPlugin(%22%5Bname%5D.css%22),%0A        new webpack.optimize.CommonsChunkPlugin(%7B%0A            names: %5B%22cover%22, %22index%22, %22pretty%22, %22slide%22, %22vendor%22%5D,%0A            children: true,%0A            async: true,%0A            filename: '%5Bname%5D.js',%0A            minChunks: Infinity%0A        %7D),%0A        new HtmlWebpackPlugin(%7B%0A            template: 'public/views/includes/header.ejs',%0A            chunks: %5B'vendor', 'index'%5D,%0A            filename: path.join(__dirname, 'public/views/build/index-header.ejs'),%0A            inject: false%0A        %7D),%0A        new HtmlWebpackPlugin(%7B%0A            template: 'public/views/includes/scripts.ejs',%0A            chunks: %5B'vendor', 'index'%5D,%0A            filename: path.join(__dirname, 'public/views/build/index-scripts.ejs'),%0A            inject: false%0A        %7D),%0A        new HtmlWebpackPlugin(%7B%0A            template: 'public/views/includes/header.ejs',%0A            chunks: %5B'vendor', 'cover'%5D,%0A            filename: path.join(__dirname, 'public/views/build/cover-header.ejs'),%0A            inject: false%0A        %7D),%0A        new HtmlWebpackPlugin(%7B%0A            template: 'public/views/includes/scripts.ejs',%0A            chunks: %5B'vendor', 'cover'%5D,%0A            filename: path.join(__dirname, 'public/views/build/cover-scripts.ejs'),%0A            inject: false%0A        %7D),%0A        new HtmlWebpackPlugin(%7B%0A            template: 'public/views/includes/header.ejs',%0A            chunks: %5B'vendor', 'pretty'%5D,%0A            filename: path.join(__dirname, 'public/views/build/pretty-header.ejs'),%0A            inject: false%0A        %7D),%0A        new HtmlWebpackPlugin(%7B%0A            template: 'public/views/includes/scripts.ejs',%0A            chunks: %5B'vendor', 'pretty'%5D,%0A            filename: path.join(__dirname, 'public/views/build/pretty-scripts.ejs'),%0A            inject: false%0A        %7D),%0A        new HtmlWebpackPlugin(%7B%0A            template: 'public/views/includes/header.ejs',%0A            chunks: %5B'vendor', 'slide'%5D,%0A            filename: path.join(__dirname, 'public/views/build/slide-header.ejs'),%0A            inject: false%0A        %7D),%0A        new HtmlWebpackPlugin(%7B%0A            template: 'public/views/includes/scripts.ejs',%0A            chunks: %5B'vendor', 'slide'%5D,%0A            filename: path.join(__dirname, 'public/views/build/slide-scripts.ejs'),%0A            inject: false%0A        %7D),
+path = require('path');%0A%0Amodule.exports = Object.assign(%7B%7D, baseConfig, %7B%0A    plugins: baseConfig.plugins.concat(%5B
 %0A   
@@ -531,16 +531,17 @@
 %7D)%0A    %5D
+)
 ,%0A%0A    o
@@ -679,14 +679,13 @@
 s'%0A    %7D
-,
 %0A%7D);%0A

Refactor webpack production config