This repository has been archived by the owner on Jul 13, 2018. It is now read-only.
forked from techqueria/site
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
executable file
·110 lines (108 loc) · 2.66 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
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");
export default {
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.UglifyJsPlugin({
compress: {
warnings: false,
screw_ie8: true,
conditionals: true,
unused: true,
comparisons: true,
sequences: true,
dead_code: true,
evaluate: true,
if_return: true,
join_vars: true
},
output: {
comments: false
}
}),
new webpack.optimize.AggressiveMergingPlugin(),
new BrotliPlugin(),
new CompressionPlugin(),
new WorkboxPlugin({
cacheId: "techqueria",
globDirectory: "dist",
globPatterns: ["index.html", "404.html", "**/*.{css,png,gif,jpg,svg,xml,js,ico,json}"],
globStrict: false,
swDest: path.join("dist", "sw.js"),
clientsClaim: true,
skipWaiting: true,
runtimeCaching: [
{
urlPattern: /\.(?:png|gif|jpg)$/,
handler: "networkFirst",
options: {
cacheName: "techqueria-image-cache"
}
},
{
urlPattern: new RegExp("https://imgur.com"),
handler: "staleWhileRevalidate"
},
{
urlPattern: new RegExp("https://google-analytics.com"),
handler: "staleWhileRevalidate"
},
{
urlPattern: new RegExp("https://twemoji.maxcdn.com"),
handler: "staleWhileRevalidate"
}
]
})
],
context: path.join(__dirname, "src"),
entry: {
app: ["./js/app"]
},
output: {
path: path.join(__dirname, "dist/assets/js"),
publicPath: "/dist/assets/js/",
filename: "[name].js"
}
};