静的エクスポート
ページを静的にエクスポートし、Nginx、GitHub Pagesなどでデプロイします。
はじめに
設定
next.config.mjs
import nextra from 'nextra'
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
output: 'export',
images: {
unoptimized: true // mandatory, otherwise won't export
}
// Optional: Change the output directory `out` -> `dist`
// distDir: "build"
}
const withNextra = nextra({
theme: 'nextra-theme-docs',
themeConfig: './theme.config.tsx'
})
export default withNextra(nextConfig)
ビルド
パッケージマネージャーに応じてbuild
コマンドを実行します
npm run build
デフォルトでは、静的エクスポートはプロジェクトルートのout
ディレクトリに保存されます。
静的エクスポートの詳細については、Next.jsのドキュメントを参照してください。