var webpack = require('webpack')
var merge = require('webpack-merge')
var baseWebpackConfig = require('./webpack.base.conf')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
var SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
var path = require('path')

// add hot-reload related code to entry chunks
Object.keys(baseWebpackConfig.entry).forEach(function (name) {
  baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name])
})

module.exports = merge(baseWebpackConfig, {
  module: {
	rules: [{
	  "test": /\.scss$/,
	  "use": [
	      "vue-style-loader",
	      {
	        "loader": "css-loader",
	        "options": {
	          "minimize": false,
	          "sourceMap": false
	        }
	      },{
	        "loader": "sass-loader",
	        "options": {
	          "sourceMap": false
	        }
	      }]
	},{
      "test": /\.vue$/,
      "loader": 'vue-loader',
      "options": {
	      "loaders": {
	        "scss": [
	          "vue-style-loader",
	          {
	            "loader": "css-loader",
	            "options": {
	              "minimize": false,
	              "sourceMap": true
	            }
	          },{
	            "loader": "sass-loader",
	            "options": {
	              "sourceMap": true
	            }
	          }
	        ]
	      }
      }
	}]
  },
  // cheap-module-eval-source-map is faster for development
  devtool: '#cheap-module-eval-source-map',
  plugins: [
    new webpack.DefinePlugin({
      'process.env': {NODE_ENV: '"development"'}
    }),
    // https://github.com/glenjamin/webpack-hot-middleware#installation--usage
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoEmitOnErrorsPlugin(),
    //new BundleAnalyzerPlugin(),
    // https://github.com/ampedandwired/html-webpack-plugin
    new HtmlWebpackPlugin({
      filename: 'index.html',
      template: 'index.html',
      favicon: path.resolve(__dirname, '..', 'favicon.ico'),
      inject: true
    }),
    new FriendlyErrorsPlugin(),
    //new SWPrecacheWebpackPlugin({
    //    cacheId: 'merlin',
	//	filename: 'service-worker.js',
    //  	staticFileGlobs: ['static/*.{html,ico}','dist/**/*.{js,html,css,png,jpg}'],
    //  	minify: true,
    //  	stripPrefix: 'static/'
    //}),
  ]
})

@@ -2169,26 +2169,24 @@
 ugin(),%0A    
-//
 new SWPrecac
@@ -2207,18 +2207,16 @@
 n(%7B%0A    
-//
     cach
@@ -2231,18 +2231,16 @@
 rlin',%0A%09
-//
 %09filenam
@@ -2263,26 +2263,24 @@
 er.js',%0A    
-//
   %09staticFil
@@ -2315,12 +2315,14 @@
 %7D','
-di
 st
+atic
 /**/
@@ -2352,18 +2352,16 @@
 '%5D,%0A    
-//
   %09minif
@@ -2373,18 +2373,16 @@
 ue,%0A    
-//
   %09strip
@@ -2403,18 +2403,16 @@
 c/'%0A    
-//
 %7D),%0A  %5D%0A

update dev plugin config