Deploy Next App

on Github pages

Installation github pages

npm i -D gh-pages

Configuration package.json

  {
  	"name": "reparability-landing",
  	"homepage": "https://nicolashedoire.github.io/reparability-landing"
  }

Ajout génération site statique

  "scripts": {
    "predeploy": "npm run build",
    "deploy": "gh-pages -d build",
    "export": "next build && next export",
  },

github action

name: Github-page-deploy

on:
  push:
    branches: [master]

jobs:
  build: 
    runs-on: ubuntu-latest 
    
    strategy:
      matrix:
        node-version: [14.x]
        
    steps:
      - name: checkout
        uses: actions/checkout@v2
        
      - name: use Node version ${{matrix.node-version}}
        uses: actions/setup-node@v2.1.5
        with:
          node-version: ${{matrix.node-version}}
        
      - run: npm i
      - run: npm run build --if-present
        env: 
          NEXT_PUBLIC_BASE_PATH: '/next-js-reparability-landing'
      - run: npm run export
        env: 
          NEXT_PUBLIC_BASE_PATH: '/next-js-reparability-landing'
      - run: touch './out/.nojekyll'
        
      - name: Deploy 🚀
        uses: JamesIves/github-pages-deploy-action@4.1.4
        with:
          branch: gh-pages # The branch the action should deploy to.
          folder: out # The folder the action should deploy.
      

Ajout des images

module.exports = {
    images: {
      loader: "imgix",
      path: "",
    },
    basePath: process.env.NEXT_PUBLIC_BASE_PATH ,
    assetPrefix: process.env.NEXT_PUBLIC_BASE_PATH
}

Créer un fichier next.config.js

Made with Slides.com