Repository navigation
Expand file tree
/
Copy pathnext.config.ts
More file actions
62 lines (57 loc) · 1.59 KB
/
Copy pathnext.config.ts
File metadata and controls
62 lines (57 loc) · 1.59 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
import setMDX from '@next/mdx';
import withSerwistInit from '@serwist/next';
import { NextConfig } from 'next';
// @ts-expect-error no official types
import withLess from 'next-with-less';
import remarkFrontmatter from 'remark-frontmatter';
import remarkMdxFrontmatter from 'remark-mdx-frontmatter';
const { NODE_ENV, CI } = process.env;
const isDev = NODE_ENV === 'development';
const withMDX = setMDX({
options: {
remarkPlugins: [remarkFrontmatter, remarkMdxFrontmatter],
rehypePlugins: [],
providerImportSource: '@mdx-js/react',
},
extension: /\.mdx?$/,
}),
withSerwist = withSerwistInit({
swSrc: 'service-worker.ts',
swDest: 'public/sw.js',
disable: isDev,
});
const rewrites: NextConfig['rewrites'] = async () => ({
beforeFiles: [
{
source: '/proxy/github.com/:path*',
destination: 'https://github.com/:path*',
},
{
source: '/proxy/raw.githubusercontent.com/:path*',
destination: 'https://raw.githubusercontent.com/:path*',
},
{
source: '/proxy/geo.datav.aliyun.com/:path*',
destination: 'https://geo.datav.aliyun.com/:path*',
},
],
afterFiles: [],
});
const redirects: NextConfig['redirects'] = async () =>
['/wiki', '/recipe', '/policy'].flatMap(route => [
{
source: `${route}/:path*`,
destination: `https://wiki.fcc-cd.dev${route}/:path*`,
permanent: true,
},
]);
export default withSerwist(
withLess(
withMDX({
pageExtensions: ['js', 'jsx', 'ts', 'tsx', 'md', 'mdx'],
output: CI ? 'standalone' : undefined,
rewrites,
redirects,
}),
),
);