如果要丟上github page,next.config.js中的output option扮演極重要的角色。
要記得設為export壓成靜態網站
不然預設是standalone就只會是一般build好的production deployment
範例
output的Value 取決於是否為Production。
//next.config.js
const isProd = process.env.NODE_ENV === 'production'
const withNextra = require('nextra')({
theme: 'nextra-theme-docs',
themeConfig: './theme.config.jsx',
})
const nextConfig = {
basePath: process.env.BASE_PATH,
assetPrefix: process.env.ASSET_PREFIX,
reactStrictMode: true,
output: isProd ? 'export' : 'standalone',
distDir: 'dist',
images: {
unoptimized: true,
}
}
module.exports = withNextra(nextConfig)