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