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

const dirApp = path.join(__dirname, 'app');
const dirAssets = path.join(__dirname, 'assets');

// Is the current build a development build
const IS_DEV = (process.env.NODE_ENV === 'dev');

module.exports = {
    entry: {
        vendor: [
            'jquery',
            'lodash'
        ],
        bundle: path.join(dirApp, 'index')
    },
    resolve: {
        modules: [
            'node_modules',
            dirAssets,
            dirApp
        ]
    },
    plugins: [
        new webpack.DefinePlugin({
            IS_DEV: IS_DEV
        }),

        new webpack.ProvidePlugin({
            // jQuery
            $: 'jquery',
            jQuery: 'jquery',
            'window.jQuery': 'jquery',
            'root.jQuery': 'jquery',

            // lodash
            '_': 'lodash'
        }),

        new HtmlWebpackPlugin({
            template: path.join(__dirname, 'index.ejs'),
            title: 'Webpack Boilerplate'
        })
    ],
    module: {
        rules: [
            // BABEL
            {
                test: /\.js$/,
                loader: 'babel-loader',
                exclude: /(node_modules)/,
                options: {
                    compact: true
                }
            },

            // STYLES
            {
                test: /\.css$/,
                use: [
                    'style-loader',
                    {
                        loader: 'css-loader',
                        options: {
                            sourceMap: IS_DEV
                        }
                    },
                ]
            },

            // CSS / SASS
            {
                test: /\.scss/,
                use: [
                    'style-loader',
                    {
                        loader: 'css-loader',
                        options: {
                            sourceMap: IS_DEV
                        }
                    },
                    {
                        loader: 'sass-loader',
                        options: {
                            sourceMap: IS_DEV,
                            includePaths: [dirAssets]
                        }
                    }
                ]
            },

            // EJS
            {
                test: /\.ejs$/,
                loader: 'ejs-loader'
            },

            // IMAGES
            {
                test: /\.(jpe*g|png|gif)$/,
                loader: 'file-loader',
                options: {
                    name: '[path][name].[ext]'
                }
            }
        ]
    }
};

@@ -118,16 +118,142 @@
 gin');%0A%0A
+// Is the current build a development build%0Aconst IS_DEV = (process.env.NODE_ENV === 'dev');%0A%0Aconst dirNode = 'node_modules';%0A
 const di
@@ -343,101 +343,85 @@
 );%0A%0A
-// Is the current build a development build%0Aconst IS_DEV = (process.env.NODE_ENV === 'dev');%0A
+const appHtmlTitle = 'Webpack Boilerplate';%0A%0A/**%0A * Webpack Configuration%0A */
 %0Amod
@@ -617,30 +617,23 @@
         
-'node_modules'
+dirNode
 ,%0A      
@@ -642,21 +642,18 @@
     dirA
-ssets
+pp
 ,%0A      
@@ -662,18 +662,21 @@
     dirA
-pp
+ssets
 %0A       
@@ -1134,37 +1134,28 @@
  title: 
-'Webpack Boilerplate'
+appHtmlTitle
 %0A       

Edit webpack config