Nuxt Nation カンファレンスが開催されます。11月12日~13日にご参加ください。
デプロイ

GitLab Pages

NuxtアプリケーションをGitLab Pagesにデプロイします。

Nuxtは、最小限の設定でGitLab Pagesへのデプロイをサポートしています。

GitLab Pagesは静的サイトのみをサポートするため、Nuxtはアプリケーションを静的なHTMLファイルに事前レンダリングします。
カスタムドメインを使用しない場合は、ビルドステップでNUXT_APP_BASE_URLをリポジトリのスラッグに設定する必要があります。:https://<group/user>.gitlab.io/<repository>/NUXT_APP_BASE_URL=/<repository>/ npm run generate

デプロイ

  1. 以下は、GitLab PagesにサイトをデプロイするためのGitLab Pagesワークフローの例です。
.gitlab-ci.yml
# Job name has to be `pages`. See https://docs.gitlab.com/ee/user/project/pages/#how-it-works
pages:
   image: node
   before_script:
      - npm ci --cache .npm --prefer-offline
   script:
      # Specify the steps involved to build your app here
      - npm run generate
   cache: # https://docs.gitlab.com/ee/ci/caching/#cache-nodejs-dependencies
      key:
         files:
         - package-lock.json
      paths:
         - .npm/
   artifacts:
      paths:
         # The directory that contains the built files to be published
         - .output/public
   # The directory that contains the built files to be published
   publish: .output/public
   rules:
      # This ensures that only pushes to the default branch 
      # will trigger a pages deploy
      - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH

詳細はこちら

GitLab Pagesのデフォルトドメイン名について詳しくは、GitLab Pagesのデフォルトドメイン名とURLをご覧ください。