-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.js
More file actions
74 lines (70 loc) · 1.73 KB
/
next.config.js
File metadata and controls
74 lines (70 loc) · 1.73 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
/** @type {import('next').NextConfig} */
const appSecurityHeaders = [
{ key: "X-XSS-Protection", value: "1; mode=block" },
];
const withPWA = require("next-pwa")({
dest: "public",
register: true,
skipWaiting: true,
disable: process.env.NODE_ENV === "development",
});
const nextConfig = {
reactStrictMode: true,
images: {
remotePatterns: [
{
protocol: "https",
hostname: "github.com",
},
{
protocol: "https",
hostname: "tvstbbuidvwgelgidaqy.supabase.co",
},
{
protocol: "https",
hostname: "aikluwlsjdrayohixism.supabase.co",
},
{
protocol: "https",
hostname: "liyuxuan.dev",
},
],
},
async headers() {
return [
{
// Apply these headers to all routes in your application.
source: "/:path*",
headers: appSecurityHeaders,
},
];
},
async redirects() {
return [
{
source: "/",
destination: "/about#top",
permanent: true,
},
];
},
webpack: (config) => {
config.plugins.push(new VeliteWebpackPlugin());
return config;
},
};
class VeliteWebpackPlugin {
static started = false;
apply(/** @type {import('webpack').Compiler} */ compiler) {
// executed three times in nextjs
// twice for the server (nodejs / edge runtime) and once for the client
compiler.hooks.beforeCompile.tapPromise("VeliteWebpackPlugin", async () => {
if (VeliteWebpackPlugin.started) return;
VeliteWebpackPlugin.started = true;
const dev = compiler.options.mode === "development";
const { build } = await import("velite");
await build({ watch: dev, clean: !dev });
});
}
}
module.exports = withPWA(nextConfig);