デプロイ
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
デプロイ
- 以下は、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