-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathnext.config.js
100 lines (93 loc) · 2.25 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
100
const path = require('path')
const dotenvLoad = require('dotenv-load')
const optimizedImages = require('next-optimized-images')
dotenvLoad()
const remarkPlugins = [
require('remark-slug'),
require('./src/lib/docs/remark-paragraph-alerts'),
[
require('remark-autolink-headings'),
{
behavior: 'append',
linkProperties: {
class: ['anchor'],
title: 'Direct link to heading',
},
},
],
require('remark-emoji'),
require('remark-footnotes'),
require('remark-images'),
[
require('remark-github'),
{ repository: 'https://github.com/SvelteStack/svelte-query' },
],
require('remark-unwrap-images'),
[
require('remark-toc'),
{
skip: 'Reference',
maxDepth: 6,
},
],
]
module.exports = optimizedImages({
pageExtensions: ['jsx', 'js', 'mdx', 'md'],
env: {
NEXT_PUBLIC_GA_TRACKING_ID: process.env.GA_TRACKING_ID || '',
SENTRY_RELEASE: process.env.VERCEL_GITHUB_COMMIT_SHA || '',
},
async redirects() {
return [
{
source: '/docs/:any*',
destination: '/:any*', // Matched parameters can be used in the destination
permanent: true,
},
]
},
experimental: {
plugins: true,
modern: true,
},
webpack: (config, { dev, isServer, ...options }) => {
config.module.rules.push({
test: /.mdx?$/, // load both .md and .mdx files
use: [
options.defaultLoaders.babel,
{
loader: '@mdx-js/loader',
options: {
remarkPlugins,
},
},
path.join(__dirname, './src/lib/docs/md-loader'),
],
})
// only compile build-rss in production server build
if (dev || !isServer) {
return config
}
// we're in build mode so enable shared caching for Notion data
process.env.USE_CACHE = 'true'
const originalEntry = config.entry
config.entry = async () => {
const entries = {
...(await originalEntry()),
}
// entries['./scripts/build-rss.js'] = './src/lib/build-rss.js'
return entries
}
return config
},
optimizeImages: {
/* config for next-optimized-images */
mozjpeg: {
quality: 70,
},
optipng: {
optimizationLevel: 3,
},
optimizeImagesInDev: true,
},
})