部署
GitLab Pages
将你的 Nuxt 应用程序部署到 GitLab Pages。
Nuxt 支持通过最少的配置部署到 GitLab Pages。
GitLab Pages 仅支持静态站点,Nuxt 会将你的应用程序预渲染为静态 HTML 文件。
如果你 不 使用自定义域名,你需要将
NUXT_APP_BASE_URL
设置为你的仓库 slug 以进行构建步骤。示例: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