forked from aws-amplify/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.mjs
86 lines (77 loc) · 2.46 KB
/
next.config.mjs
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
import { createRequire } from 'module';
import dotenv from 'dotenv';
import createMDX from '@next/mdx';
import rehypeMdxCodeProps from 'rehype-mdx-code-props';
const require = createRequire(import.meta.url);
import rehypeImgSize from 'rehype-img-size';
import remarkGfm from 'remark-gfm';
import rehypeSlug from 'rehype-slug';
dotenv.config({ path: './.env.custom' });
const nextJSConfig = () => {
const withMDX = createMDX({
extension: /\.mdx$/,
options: {
remarkPlugins: [remarkGfm],
rehypePlugins: [
[rehypeImgSize, { dir: 'public' }],
rehypeMdxCodeProps,
rehypeSlug
]
}
});
const shouldAnalyzeBundles = process.env.ANALYZE === 'true';
let nextConfig = withMDX({
output: 'export',
distDir: 'client/www/next-build',
generateBuildId: async () => {
return 'amplify-docs';
},
env: {
BUILD_ENV: process.env.BUILD_ENV,
ALGOLIA_APP_ID: process.env.ALGOLIA_APP_ID,
ALGOLIA_API_KEY: process.env.ALGOLIA_API_KEY,
ALGOLIA_INDEX_NAME: process.env.ALGOLIA_INDEX_NAME,
nextImageExportOptimizer_imageFolderPath: 'public',
nextImageExportOptimizer_exportFolderPath: 'out',
nextImageExportOptimizer_quality: '75',
nextImageExportOptimizer_storePicturesInWEBP: 'true',
nextImageExportOptimizer_exportFolderName: 'nextImageExportOptimizer',
// If you do not want to use blurry placeholder images, then you can set
// nextImageExportOptimizer_generateAndUseBlurImages to false and pass
// `placeholder="empty"` to all <ExportedImage> components.
nextImageExportOptimizer_generateAndUseBlurImages: 'true'
},
images: {
loader: 'custom',
imageSizes: [],
deviceSizes: [450, 1920]
},
pageExtensions: ['js', 'jsx', 'mdx', 'tsx', 'ts'],
typescript: {
// !! WARN !!
// Dangerously allow production builds to successfully complete even if
// your project has type errors.
// !! WARN !!
ignoreBuildErrors: true
},
trailingSlash: true,
transpilePackages: [
'@algolia/autocomplete-shared',
'next-image-export-optimizer'
]
});
if (shouldAnalyzeBundles) {
const withNextBundleAnalyzer = require('next-bundle-analyzer')({
format: ['json'],
reportDir: '../.github/analyze',
json: {
filter: {
pages: true
}
}
});
nextConfig = withNextBundleAnalyzer(nextConfig);
}
return nextConfig;
};
export default nextJSConfig;