Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add GitLab Pages deploy option #1548

Merged
merged 6 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions content/0.index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ sections:
- src: /assets/integrations/koyeb.svg
alt: Koyeb
to: /deploy/koyeb
- src: /assets/integrations/gitlab.svg
alt: GitLab
to: /deploy/gitlab
- src: /assets/integrations/tailwind.svg
alt: Tailwind CSS
to: /modules/tailwindcss
Expand Down
90 changes: 90 additions & 0 deletions content/3.deploy/gitlab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
---
title: GitLab Pages
description: 'Deploy your Nuxt Application to GitLab Pages.'
logoSrc: '/assets/integrations/gitlab.svg'
category: Hosting
website: 'https://docs.gitlab.com/ee/user/project/pages'
---

Nuxt supports deploying on the [GitLab Pages](https://docs.gitlab.com/ee/user/project/pages) with minimal configuration.

::caution
GitLab Pages only support static sites, Nuxt will pre-render your application to static HTML files.
::

## Setup

1. GitLab Pages only support deployment from `public/` directory. Rename the `public/` directory to a collision-free alternative first:

```bash [Terminal]
mv public static
```

2. Add the following to your nuxt.config.ts:

```ts [nuxt.config.ts]
import path from 'node:path';

export default defineNuxtConfig({
nitro: {
// Output directories for production bundle
output: {
publicDir: path.join(__dirname, "public"),
Atinux marked this conversation as resolved.
Show resolved Hide resolved
},
},
// Customize default directory structure used by Nuxt
dir: {
public: 'static',
Atinux marked this conversation as resolved.
Show resolved Hide resolved
static: 'static'
}
})
```

3. Ensure that `generate` script is defined within the project's `package.json` file to define how to generate the application:

```json [package.json]
{
"scripts": {
"generate": "nuxt generate"
Atinux marked this conversation as resolved.
Show resolved Hide resolved
}
}
```

## Deployment

1. Here is an example GitLab Pages workflow to deploy your site to GitLab Pages:

```yaml [.gitlab-ci.yml]
# The Docker image that will be used to build your app
image: node:lts
# Functions that should be executed before the build script is run
before_script:
- npm install
cache:
paths:
- # Directories that are cached between builds
- node_modules/
pages:
script:
# Specify the steps involved to build your app here
- npm run generate
artifacts:
paths:
# The directory that contains the built files to be published.
# This must be called "public".
- public
rules:
# This ensures that only pushes to the default branch
# will trigger a pages deploy
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
```

## Learn more

::read-more{to="https://docs.gitlab.com/ee/user/project/pages/getting_started_part_one.html#project-website-examples" target="_blank"}
Head over **GitLab Pages default domain names and URLs** to learn more about the GitLab Pages default domain names.
::

::read-more{to="https://docs.gitlab.com/ee/user/project/pages/" target="_blank"}
Head over **GitLab Pages documentation** to learn more about the GitLab Pages deployment preset.
::
1 change: 1 addition & 0 deletions public/assets/integrations/gitlab.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.