Begueradj   Archives  About

Nuxt.js deployment on Gitlab

How to deploy your Nuxt.js application on Gitlab for continuous integration?

First create a Gitlab CI YAML file and name it .gitlab-ci.yml with the following commands:

image: node

before_script:
  - npm install

cache:
  paths:
    - node_modules/

pages:
  script:
    - npm run generate
  artifacts:
    paths:
      - public
  only:
    - master

Then in nuxt.config.js, add these configuration lines:

/**
* Gitlab
*/
router: {
   base: '/whatEverName/',  
},
generate: {
   dir: 'public',
},

After running the CI job, and on the project’s repository, go to Settings then Pages and click on the link https://namespace.gitlab.io/whatEverName to navigate your application.

Written on Nov 18, 2018.