-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathnext.config.js
48 lines (42 loc) · 1.3 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
// @ts-check
const nextBuildId = require("next-build-id")
const shouldAnalyzeBundles = process.env.ANALYZE === "true"
/** @type { import('next').NextConfig } */
let nextConfig = {
reactStrictMode: true,
eslint: {},
output: process.env.NODE_ENV === "production" ? "export" : "standalone",
distDir: "out/dist",
poweredByHeader: false,
webpack: (config) => {
return config
},
// When when app is exported as SPA and served in a sub-folder
assetPrefix: process.env.NEXT_PUBLIC_BASE_PATH
? `${process.env.NEXT_PUBLIC_BASE_PATH}/`
: undefined,
// https://nextjs.org/docs/api-reference/next.config.js/custom-page-extensions#including-non-page-files-in-the-pages-directory
pageExtensions: ["page.tsx"],
generateBuildId: () => nextBuildId({ dir: __dirname }),
}
// rewrite rules affect only development mode, since Next router will return 404 for paths that only exist in react-router
if (process.env.NODE_ENV !== "production") {
nextConfig = {
...nextConfig,
async rewrites() {
return [
{
source: "/:any*",
destination: "/",
},
]
},
}
}
if (shouldAnalyzeBundles) {
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: true,
})
nextConfig = withBundleAnalyzer(nextConfig)
}
module.exports = nextConfig