0

We have a very large nuxt static site. Which we are implementing incremental builds using some of the strategies from this github thread: https://github.com/nuxt/nuxt.js/issues/6138

We are dividing up the build process across multiple calls like this nuxt generate -p 5 where the 5 is the page number.

In the nuxt.config.js file

    generate: {
      async routes () {
        const routes = []
        const pageIndex = process.argv.indexOf('-p')
        const cacheData = await cache.get(`page-${pageIndex}.json`)
        cacheData.data.data.forEach((product) => {
          routes.push({
            route: '/' + product.url,
            payload: product
          })
        })

        return routes
     },
     ...
   }

But we would like to separate the output of the generation in the same way. So the build output would go into /dist-1 /dist-2 etc.

like this:

  hooks: {
    'generate:before' (nuxt, generateOptions) {

      // HOW DO YOU CHANGE THE OPTIONS HERE !?!!?!?  THIS DOESNT WORK
      generateOptions.dir = generateOptions.dir + `-${process.argv.indexOf('-p')}`

      console.log('generate:before ', generateOptions.dir)
    },

This mostly because it seems not possible to keep the generate function from emptying the dist folder.

So the question is how to set the dist folder at run time? Any suggestion are welcome.

4

0 回答 0