Nuxt/Vue with Static Hosting: generate pages

I’ve followed this tutorial and added a few pages to my project.
Running Nuxt locally I could see all the pages but when I tried to generate the static version of the app, it only generated the 200.html and not the index.html or the content generated on Builder.io . After some research I’ve found out that this need to be added to the nuxt.config.js :

import { builder } from '@builder.io/vue'

export default {
  target: 'static',

  build: {
    extend(config, context) {
      if (context.isServer) {
        builder.init('USE_YOUR_KEY_HERE')
        builder
          .getAll('page', {
            options: { noTargeting: true },
            omit: 'data.blocks',
          })
          .then((results) => {
            results.forEach((result) => {
              this.buildContext.options.generate.routes.push(result.data.url)
            })
          })
      }
    },
  },
  generate: {
    routes: ['/']
  }
}

Is that the correct approach? Or do you recommend any other solution?
Would be nice to have the Static Hosting covered on the tutorial if possible.

By the way, I just started playing with the Builder.io and I have to say: it’s fantastic! Great work!

Hi @maat thanks for the feedback! I’ll share this with the Builder.io team. We don’t have any documentation or examples yet for SSG with Nuxt but if this approach has been working for you then go with it! It might also be helpful for the community to post any issues you run into along way. And while you may have already seen these, here are the current starters we have for our Vue SDK that may help:

Vue Starters
Vue SDK Docs

Thanks AJ!
I will check it out…

Cheers

1 Like