-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
104 lines (83 loc) · 2.71 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
101
102
/** @type {import('next').NextConfig} */
const { PHASE_DEVELOPMENT_SERVER } = require('next/constants')
const isProd = process.env.NODE_ENV === 'production';
// Docker deployment
// To add support for Docker to an existing project,
// you can directly set the `dockerDeploymentEnabled` property to `true`
const dockerDeploymentEnabled = false;
// Static Exports
let exportHtmlEnabled = process.env.EXPORT_ENABLED == 'false' ? false : true;
if (dockerDeploymentEnabled) exportHtmlEnabled = false;
//
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
// Use the "https://yourusername.github.io/my-subdirectory/ " in production and localhost for development.
// !!!IMPORTANT: You need to modify the relevant paths in the "scripts/config-rootdir-of-publishing-source.js" at the same time
/*
basePath: isProd ? '/my-subdirectory' : undefined,
assetPrefix: isProd ? '/my-subdirectory/' : undefined,
*/
// disable source map
productionBrowserSourceMaps: true,
// !!! for docker (`output: 'standalone'`)
// This will create a folder at .next/standalone which can then be deployed on its own without installing node_modules.
output: dockerDeploymentEnabled ? 'standalone' : !exportHtmlEnabled ? undefined : 'export',
// image optimize
images: {
unoptimized: true
},
// add a page route with html extension
// Rename the file under pages directory to `.html.tsx`
pageExtensions: ['html.jsx', 'jsx', 'js', 'tsx', 'ts'],
// omit the html extension
trailingSlash: false,
webpack: (config) => {
config.module.rules.push({
test: /\.svg$/,
use: ["@svgr/webpack"]
});
return config;
},
env: {
exportHtml: `${exportHtmlEnabled}`
}
/*
// change the api route
async rewrites() {
return [
{
source: '/core-api/posts',
destination: '/api/posts',
}
]
},
async redirects() {
return [
{
source: '/',
destination: process.env.NODE_ENV === 'development' ? '/index.html' : '/',
permanent: true,
},
]
},
async headers() {
return [
{
source: '/about',
headers: [
{
key: 'x-custom-header',
value: 'my custom header value',
},
{
key: 'x-another-custom-header',
value: 'my other custom header value',
},
],
},
]
},
*/
}
module.exports = nextConfig