Next Deploy Github Page

  1. 在project root新增 .github/workflows/deploy.yml

  2. next.config.js 新增

    • const isProd = process.env.NODE_ENV === 'production'
    • module.exports = {
          ...
          assetPrefix: isProd ? '/j-p1/' : ''
      }
    • example
      /** @type {import('next').NextConfig} */
      //
      const isProd = process.env.NODE_ENV === 'production'
      
      const nextConfig = {
        reactStrictMode: true,  
        assetPrefix: isProd ? '/j-p1/' : ''
      }
      
      module.exports = nextConfig
  3. 設定 package.json “scripts”: { “dev”: “next dev”, “build”: “next build”, “start”: “next start”, “lint”: “next lint”, “export”: “next export” },

FAQ

0%