-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
71 lines (68 loc) · 1.89 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* eslint-env node */
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const WorkboxPlugin = require("workbox-webpack-plugin");
const config = {
output: {
path: path.resolve(__dirname, "public"),
filename: "argoose.js",
},
module: {
rules: [{ test: /\.js$/, use: "babel-loader" }],
},
plugins: [
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
title: "Argoose",
template: "./src/index.html",
favicon: "./static/favicon.ico",
}),
new WorkboxPlugin.GenerateSW({
clientsClaim: true,
skipWaiting: true,
include: [/\.html$/, /\.js$/, /\.css$/],
directoryIndex: "/index.html",
navigateFallback: "/index.html",
additionalManifestEntries: ["/index.html"],
runtimeCaching: [
{
handler: "StaleWhileRevalidate",
options: {
cacheName: "google-fonts",
expiration: { maxEntries: 20 },
},
urlPattern: ({ url }) =>
url.origin === "https://fonts.googleapis.com" ||
url.origin === "https://fonts.gstatic.com",
},
{
handler: "StaleWhileRevalidate",
options: {
cacheName: "product-images",
expiration: { maxEntries: 100 },
},
urlPattern: ({ url }) => url.origin === "https://media.4rgos.it",
},
{
handler: "StaleWhileRevalidate",
options: {
cacheName: "product-json",
expiration: { maxEntries: 1 },
},
urlPattern: ({ url }) =>
url.pathname === "/front-end-test/products.json",
},
],
}),
],
devServer: {
port: 3000,
contentBase: "./public",
hot: true,
historyApiFallback: {
index: "index.html",
},
},
};
module.exports = config;