This repository has been archived by the owner on Dec 2, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathwebpack.client.prod.config.js
84 lines (81 loc) · 2.12 KB
/
webpack.client.prod.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
'use strict';
const { resolve } = require('path');
const webpack = require('webpack');
const ManifestPlugin = require('webpack-manifest-plugin');
const PwaManifest = require('webpack-pwa-manifest');
const { GenerateSW } = require('workbox-webpack-plugin');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const RobotstxtPlugin = require('robotstxt-webpack-plugin');
const config = {
mode: 'production',
output: {
filename: '[name].[contenthash].bundle.js',
chunkFilename: '[name].[contenthash].[id].bundle.js',
},
plugins: [
new webpack.optimize.AggressiveMergingPlugin(),
new ManifestPlugin(),
// https://developer.mozilla.org/en-US/docs/Web/Manifest
new PwaManifest({
filename: 'manifest.webmanifest',
name: 'ssr-sample',
short_name: 'ssr-sample',
theme_color: '#3498db',
description: 'introducing SPA and SSR',
background_color: '#f5f5f5',
crossorigin: 'use-credentials',
icons: [
{
src: resolve('./assets/avatar.png'),
sizes: [96, 128, 192, 256, 384, 512],
},
],
}),
new GenerateSW({
clientsClaim: true,
skipWaiting: true,
include: [/\.js$/],
runtimeCaching: [
{
urlPattern: new RegExp('.'), // for start_url
handler: 'StaleWhileRevalidate',
},
{
urlPattern: new RegExp('api|graphql'),
handler: 'NetworkFirst',
},
{
urlPattern: new RegExp('https://fonts.googleapis.com|https://fonts.gstatic.com'),
handler: 'CacheFirst',
},
],
}),
new RobotstxtPlugin(),
new BundleAnalyzerPlugin({
analyzerMode: 'static',
openAnalyzer: false,
}),
],
performance: {
maxEntrypointSize: 512000,
maxAssetSize: 512000,
},
optimization: {
runtimeChunk: {
name: 'manifest',
},
minimize: true,
splitChunks: {
minSize: 10000,
maxSize: 250000,
cacheGroups: {
vendor: {
test: /node_modules/,
chunks: 'all',
enforce: true,
},
},
},
},
};
module.exports = config;