-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
77 lines (74 loc) · 1.84 KB
/
next.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
const withBundleAnalyzer = require("@zeit/next-bundle-analyzer");
const withOffline = require("next-offline");
const path = require("path");
const dotEnvResult = require("dotenv").config({
path: path.resolve(__dirname, ".env")
});
if (dotEnvResult.error) {
throw dotEnvResult.error;
}
const nextConfig = {
workboxOpts: {
exclude: [/\.(?:png|jpg|jpeg|svg)$/],
runtimeCaching: [
{
urlPattern: /\.(?:png|jpg|jpeg|svg)$/,
handler: "CacheFirst",
options: {
cacheName: "images",
expiration: {
maxEntries: 25
}
}
},
{
urlPattern: /^https?.*/,
handler: "NetworkFirst",
options: {
cacheName: "offlineCache",
expiration: {
maxEntries: 1
}
}
},
{
urlPattern: /api/,
handler: "NetworkFirst",
options: {
cacheableResponse: {
statuses: [0, 200],
headers: {
"x-test": "true"
}
}
}
}
]
},
analyzeServer: ["server", "both"].includes(process.env.BUNDLE_ANALYZE),
analyzeBrowser: ["browser", "both"].includes(process.env.BUNDLE_ANALYZE),
bundleAnalyzerConfig: {
server: {
analyzerMode: "static",
reportFilename: "../bundles/server.html"
},
browser: {
analyzerMode: "static",
reportFilename: "../bundles/client.html"
}
},
compress: false,
env: {
SESSION_SECRET: process.env.SESSION_SECRET,
DB_HOST: process.env.DB_HOST,
DB_USER: process.env.DB_USER,
DB_PASSWORD: process.env.DB_PASSWORD,
HOST_SERVER: process.env.HOST_SERVER,
HOST_CLIENT: process.env.HOST_CLIENT,
GA_TRACKING_ID: process.env.GA_TRACKING_ID
},
webpack(config) {
return config;
}
};
module.exports = withBundleAnalyzer(withOffline(nextConfig));