- 
                Notifications
    You must be signed in to change notification settings 
- Fork 11
10. Deployment
Nuxt.js comes with a set of useful commands, both for development and production purpose. Nuxt.js lets your choose between three modes to deploy your application: Server Rendered, SPA or Static Generated.
To deploy, instead of running nuxt, you probably want to build ahead of time. Therefore, building and starting are separate commands:
$ nuxt build
$ nuxt startThe package.json like follows is recommended:
{
  "name": "my-app",
  "dependencies": {
    "nuxt": "latest"
  },
  "scripts": {
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "nuxt start"
  }
}¡Run now to deploy. Every time you run now, you get a new deployment!
Nuxt.js gives you the ability to host your web application on any static hosting.
To generate our web application into static files:
$ nuxt generateIt will create a dist folder with everything inside ready to be deployed on a static hosting site.
As our project has dynamic routes, it is necessary to add a special configuration to our nuxt.confi.js file, particularly in this case our dynamic routes would be the details of each Gist.
// Dynamic routes are ignored by the generate command.
const axios = require('axios')
module.exports = {
  generate: {
    routes: function () {
      return axios.get('https://api.github.com/users/khriztianmoreno/gists')
        .then((res) => {
          return res.data.map((gist) => {
            return '/post/' + gist.id
          })
        })
    }
  }
}To see these steps complete, you can change to the 10-deployment branch in this repository.
Hello, my name is Cristian Moreno.
I'm a community leader and altruistic speaker, JavaScript/Node.js evangelist and FullStack Javascript Developer. Currently co-organize Medellin.js (Biggest JavaScript user group in Colombia), Avanet and Azure Cloud Medellin communities.
I love developing things, especially ideas, giving them a new perspective and making them shine! products and applications come after I transform ideas into code; I'm passionate about software development and related stuff.