-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathnext.config.js
99 lines (91 loc) · 2.59 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/** @type {import('next').NextConfig} */
const locales = require("./locales.js");
const PicoSanity = require("picosanity");
const client = new PicoSanity({
dataset: process.env.NEXT_PUBLIC_SANITY_DATASET || "development",
projectId: process.env.NEXT_PUBLIC_SANITY_PROJECT_ID || "",
apiVersion: "2021-03-25",
useCdn: process.env.NODE_ENV === "production",
});
module.exports = {
swcMinify: true,
reactStrictMode: true,
i18n: {
locales,
defaultLocale: "en",
localeDetection: false,
},
async rewrites() {
return {
afterFiles: [
{ source: "/sitemap.xml", destination: "/api/sitemap-xml" },
{ source: "/cms", destination: "/cms/index.html" },
{ source: "/cms/:path*", destination: "/cms/index.html" },
],
};
},
async redirects() {
const redirects = await client.fetch(
`*[_type == "redirect"]{ source, destination, permanent }`,
);
return redirects;
},
/**
* `dangerouslyAllowSVG` is a property in Next.js that allows loading of SVG images with external resources.
* However, it should be used with caution due to potential security vulnerabilities.
* Make sure to understand the risks and take appropriate security measures before using it.
*
* Read more: https://nextjs.org/docs/api-reference/next/image#dangerously-allow-svg
*/
images: {
domains: ["cdn.sanity.io", "images.unsplash.com"],
dangerouslyAllowSVG: true,
contentDispositionType: "attachment",
contentSecurityPolicy: "default-src 'self'; script-src 'none'; sandbox;",
unoptimized: true,
},
async headers() {
const headers = [
{
source: "/opengraph-image",
headers: [{ key: "Access-Control-Allow-Origin", value: "*" }],
},
];
const preventIndexing = await client.fetch(
`*[_id == "config_seo"][0].preventIndexing`,
);
if (
process.env.NEXT_PUBLIC_VERCEL_ENV !== "production" ||
preventIndexing
) {
headers.push({
headers: [
{
key: "X-Robots-Tag",
value: "noindex",
},
],
source: "/:path*",
});
}
return headers;
},
webpack(config, { isServer }) {
config.module.rules.push({
test: /\.svg$/,
use: ["@svgr/webpack"],
});
if (!isServer) {
config.optimization.splitChunks.cacheGroups = {
...config.optimization.splitChunks.cacheGroups,
swiper: {
test: /[\\/]node_modules[\\/](swiper)[\\/]/,
name: "swiper",
priority: 10,
reuseExistingChunk: false,
},
};
}
return config;
},
};