英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论