Nuxt 3(nuxt generate)更改静态输出目录?

huangapple go评论49阅读模式
英文:

Nuxt 3 (nuxt generate) change static output directory?

问题

Nuxt 2中,我们可以指定输出目录:

export default {
  target: 'static',

  generate: {
    dir: 'build/_site',
  },
}

现在我正在使用Nuxt 3,但无法弄清楚如何在运行generate时指定输出目录。generate支持是否已移除?

英文:

Nuxt 2 we were able to specify the output directory:

export default {
  target: 'static',

  generate: {
    dir: 'build/_site',
  },
}

Now I'm using Nuxt 3 and cannot figure out how to specify the output directory when running generate. Was the generate support removed?

答案1

得分: 5

In nuxt3 it can be done by overriding nitro's config in nuxt.config.ts like this:

const path = require('path');

// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  ...
  nitro: {
    output: {
      publicDir: path.join(__dirname, 'your path here')
    }
  },
  ...
}

You can check Nitro's documentation

英文:

In nuxt3 it can be done by overriding nitro's config in nuxt.config.ts like this:

const path = require('path');

// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  ...
  nitro: {
    output: {
      publicDir: path.join(__dirname, 'your path here')
    }
  },
  ...
}

You can check Nitro's documetantion

huangapple
  • 本文由 发表于 2023年3月21日 03:36:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/75794580-2.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定