-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathnext.config.js
More file actions
63 lines (58 loc) · 1.74 KB
/
next.config.js
File metadata and controls
63 lines (58 loc) · 1.74 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
const path = require('path')
const withNextra = require('nextra')({
theme: 'nextra-theme-docs',
themeConfig: './theme.config.jsx'
})
module.exports = withNextra({
async headers() {
return [
{
source: "/:path*",
headers: [
{ key: "X-Content-Type-Options", value: "nosniff" },
{ key: "X-Frame-Options", value: "SAMEORIGIN" },
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
],
},
];
},
webpack(config) {
const snippetsDir = path.join(__dirname, 'snippets')
// Exclude snippets from pre-loaders (React Fast Refresh, etc.)
for (const rule of config.module.rules) {
if (rule.enforce === 'pre') {
rule.exclude = [].concat(rule.exclude || [], snippetsDir)
}
}
// Inject into oneOf so our rule takes precedence over the SWC loader
const rawRule = {
test: /\.js$/,
include: snippetsDir,
resourceQuery: /raw/,
type: 'asset/source',
}
const oneOfRule = config.module.rules.find(r => Array.isArray(r.oneOf))
if (oneOfRule) {
oneOfRule.oneOf.unshift(rawRule)
} else {
config.module.rules.unshift(rawRule)
}
return config
},
async redirects() {
return [
{
source: "/Loading/Find-Above-The-Fold-Lazy-Loades-Images",
destination: "/Loading/Find-Above-The-Fold-Lazy-Loaded-Images",
permanent: true,
},
{
source: "/Loading/Inline-Script-Info-and-Size-Including__NEXT_DATA",
destination: "/Loading/SSR-Hydration-Data-Analysis",
permanent: true,
},
];
},
});
// If you have other Next.js configurations, you can pass them as the parameter:
// module.exports = withNextra({ /* other next.js config */ })