const webpack = require("webpack");
const path = require("path");

// Workbox
const WorkboxPlugin = require("workbox-webpack-plugin");
// Brotli
const BrotliPlugin = require("brotli-webpack-plugin");
// GZip
const CompressionPlugin = require("compression-webpack-plugin");

module.exports = {
  mode: "production",
  module: {
    rules: [{
      test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
      loader: "url-loader"
    },
    {
      test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-c9])?$/,
      loader: "url-loader"
    },
    {
      test: /\.js?$/,
      loader: "babel-loader",
      exclude: /node_modules/,
      query: {
        cacheDirectory: true
      }
    },
    {
      test: /\.css$/,
      use: ["style-loader", "css-loader"]
    },
    {
      test: /\.(gif|png|jpe?g|svg)$/i,
      use: [
        "file-loader",
        {
          loader: "image-webpack-loader"
        }
      ]
    }
    ]
  },
  plugins: [
    new webpack.optimize.ModuleConcatenationPlugin(),
    new webpack.ProvidePlugin({
      fetch: "imports-loader?this=>global!exports?global.fetch!whatwg-fetch"
    }),
    new webpack.optimize.AggressiveMergingPlugin(),
    new BrotliPlugin(),
    new CompressionPlugin(),
    new WorkboxPlugin.GenerateSW({
      cacheId: "fvcproductions",
      swDest: "sw.js",
      globDirectory: ".",
      globPatterns: ["./dist/index.html", "./dist/404.html", "./dist/offline/index.html", "./dist/**/*.{js,css,png,svg,jpg,jpeg}"],
      offlineGoogleAnalytics: true,
      clientsClaim: true,
      skipWaiting: true,
      runtimeCaching: [{
        urlPattern: /\.(?:html)$/,
        handler: "networkFirst",
        options: {
          cacheName: "posts-cache",
          expiration: {
            maxEntries: 50
          },
        }
      },
      {
        urlPattern: /\.(?:png|gif|jpg|svg|ico|jpeg|css|js)$/,
        handler: "cacheFirst",
        options: {
          cacheName: "assets-cache"
        }
      },
      {
        urlPattern: new RegExp("https://twemoji.maxcdn.com"),
        handler: "staleWhileRevalidate"
      },
      {
        urlPattern: new RegExp("https://i.imgur.com"),
        handler: "staleWhileRevalidate"
      },
      {
        urlPattern: new RegExp("https://www.google-analytics.com"),
        handler: "staleWhileRevalidate"
      },
      {
        urlPattern: new RegExp("https://cdn.onesignal.com"),
        handler: "staleWhileRevalidate"
      }
      ]
    })
  ],
  context: path.join(__dirname, "src"),
  entry: {
    app: ["./js/app"]
  },
  output: {
    filename: path.join("assets", "js", "[name].js"),
    path: path.join(__dirname, "dist"),
  }
};

@@ -1315,16 +1315,21 @@
 tory: %22.
+/dist
 %22,%0A     
@@ -1345,23 +1345,16 @@
 erns: %5B%22
-./dist/
 index.ht
@@ -1359,23 +1359,16 @@
 html%22, %22
-./dist/
 404.html
@@ -1371,23 +1371,16 @@
 html%22, %22
-./dist/
 offline/
@@ -1397,15 +1397,8 @@
 %22, %22
-./dist/
 **/*

change path