-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.js
More file actions
108 lines (108 loc) · 2.83 KB
/
next.config.js
File metadata and controls
108 lines (108 loc) · 2.83 KB
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
const path = require("path");
const webpack = require("webpack");
const withPlugins = require("next-compose-plugins");
const withSass = require("@zeit/next-sass");
const withImages = require("next-images");
const withSize = require("next-size");
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const withOffline = require("next-offline");
const { parsed: localEnv } = require("dotenv").config();
module.exports = withPlugins([withSass, withSize, withOffline], {
//target: 'serverless',
poweredByHeader: false,
reactStrictMode: true,
// staticFolder: '/static',
// distDir: 'build',
// Start of next-offline config for service worker:
// generateInDevMode: true,
transformManifest: manifest => ["/"].concat(manifest), // add the homepage to the cache
// workboxOpts: {
// swDest: "static/service-worker.js"
// },
// experimental: {
// async rewrites() {
// return [
// {
// source: "/service-worker.js",
// destination: "/_next/static/service-worker.js"
// }
// ];
// }
// },
workboxOpts: {
swDest: "static/service-worker.js",
// runtimeCaching: [
// {
// urlPattern: /^https?.*/,
// handler: "NetworkFirst",
// options: {
// cacheName: "offlineCache",
// expiration: {
// maxEntries: 50,
// maxAgeSeconds: 30 * 24 * 60 * 60, // 1 month
// purgeOnQuotaError: true
// }
// }
// }
// ]
runtimeCaching: [
{
// urlPattern: /^https?.*/,
urlPattern: /.*\.(?:png|jpg|jpeg|svg|gif)/,
handler: "NetworkFirst",
options: {
cacheName: "https-calls",
networkTimeoutSeconds: 15,
expiration: {
maxEntries: 300,
maxAgeSeconds: 1 * 60 * 60 // 1 hour
},
cacheableResponse: {
statuses: [0, 200]
}
}
}
]
},
experimental: {
async rewrites() {
return [
{
source: "/service-worker.js",
destination: "/_next/static/service-worker.js"
}
];
}
},
// End Of next-offline config
webpack(config, options) {
config.module.rules.push(
{
test: /\.svg$/,
use: [
{
loader: "babel-loader"
},
{
loader: "react-svg-loader",
options: {
jsx: true // true outputs JSX tags
}
}
]
},
{
test: /\.(png|jpg|jpeg|gif|eot|ttf|woff|woff2)$/,
use: {
loader: "url-loader"
}
}
);
config.plugins.push(new OptimizeCSSAssetsPlugin({}), new webpack.EnvironmentPlugin(localEnv));
// Fixes npm packages that depend on `fs` module
config.node = {
fs: "empty"
};
return config;
}
});