This repository has been archived by the owner on Apr 19, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
webpack.prod.js
69 lines (67 loc) 路 1.65 KB
/
webpack.prod.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
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.InjectManifest({
swDest: "sw.js",
globDirectory: "./dist",
globPatterns: ["index.html", "404.html", "**/*.{js,css,png,svg,jpg,jpeg}"]
}),
new WorkboxPlugin.GenerateSW()
],
context: path.join(__dirname, "assets"),
entry: {
app: ["./js/app"]
},
output: {
filename: path.join("assets", "js", "[name].js"),
path: path.join(__dirname, "dist")
}
};