Open History to see the last commit
1const path = require('path')
2const dotenvLoad = require('dotenv-load')
3const optimizedImages = require('next-optimized-images')
4dotenvLoad()
5β
6const remarkPlugins = [
7 require('remark-slug'),
8 require('./src/lib/docs/remark-paragraph-alerts'),
9 [
10 require('remark-autolink-headings'),
11 {
12 behavior: 'append',
13 linkProperties: {
14 class: ['anchor'],
15 title: 'Direct link to heading',
16 },
17 },
18 ],
19β
20 require('remark-emoji'),
21 require('remark-footnotes'),
22 require('remark-images'),
23 [
24 require('remark-github'),
25 { repository: 'https://github.com/tannerlinsley/react-query' },
26 ],
27 require('remark-unwrap-images'),
28 [
29 require('remark-toc'),
30 {
31 skip: 'Reference',
32 maxDepth: 6,
33 },
34 ],
35]
36β
37module.exports = optimizedImages({
38 pageExtensions: ['jsx', 'js', 'mdx', 'md'],
39 env: {
40 NEXT_PUBLIC_GA_TRACKING_ID: process.env.GA_TRACKING_ID || '',
41 SENTRY_RELEASE: process.env.VERCEL_GITHUB_COMMIT_SHA || '',
42 },
43 async redirects() {
44 return [
45 {
46 source: '/docs/:any*',
47 destination: '/:any*', // Matched parameters can be used in the destination
48 permanent: true,
49 },
50 ]
51 },
52 experimental: {
53 plugins: true,
54 modern: true,
55 },
56 webpack: (config, { dev, isServer, ...options }) => {
57 config.module.rules.push({
58 test: /.mdx?$/, // load both .md and .mdx files
59 use: [
60 options.defaultLoaders.babel,
61 {
62 loader: '@mdx-js/loader',
63 options: {
64 remarkPlugins,
65 },
66 },
67 path.join(__dirname, './src/lib/docs/md-loader'),
68 ],
69 })
70β
71 // only compile build-rss in production server build
72 if (dev || !isServer) {
73 return config
74 }
75β
76 // we're in build mode so enable shared caching for Notion data
77 process.env.USE_CACHE = 'true'
78β
79 const originalEntry = config.entry
80 config.entry = async () => {
81 const entries = {
82 ...(await originalEntry()),
83 }
84 // entries['./scripts/build-rss.js'] = './src/lib/build-rss.js'
85 return entries
86 }
87β
88 return config
89 },
90 optimizeImages: {
91 /* config for next-optimized-images */
92 mozjpeg: {
93 quality: 70,
94 },
95 optipng: {
96 optimizationLevel: 3,
97 },
98 optimizeImagesInDev: true,
99 },
100})