-
Notifications
You must be signed in to change notification settings - Fork 1
/
next.config.mjs
50 lines (41 loc) · 1.2 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
// @ts-check
import pkg from './package.json' assert { type: 'json' };
import VERSION from './scripts/compute-version.js';
import bundleAnalyzer from '@next/bundle-analyzer';
import remarkFrontmatter from 'remark-frontmatter';
import rehypePrism from 'rehype-prism-plus';
import mdx from '@next/mdx';
const withBundleAnalyzer = bundleAnalyzer({
enabled: process.env.ANALYZE === 'true',
});
const withMDX = mdx({
extension: /\.mdx?$/,
options: {
remarkPlugins: [remarkFrontmatter],
rehypePlugins: [rehypePrism],
providerImportSource: '@mdx-js/react',
},
});
const version = String(VERSION);
console.log(`\n\nRunning version: ${version}\n`);
const isProduction = 'production' === `${process.env.NODE_ENV}`;
const basePath = isProduction ? `/${pkg.name}` : '';
/**
* @type {import('next').NextConfig}
**/
const nextConfig = {
swcMinify: true,
compiler: {
removeConsole: process.env.NODE_ENV === 'production',
reactRemoveProperties: true,
},
trailingSlash: true,
reactStrictMode: true,
basePath,
env: {
ASSETS_PREFIX: basePath,
VERSION: version,
},
pageExtensions: ['ts', 'tsx', 'js', 'jsx', 'md', 'mdx'],
};
export default withMDX(withBundleAnalyzer(nextConfig));