在Nuxt中设置输出文件夹的路径 [英] Set path to output folder in Nuxt
问题描述
在Windows中工作,我可以使用自己的nuxt项目生成一个静态网站
Working in windows, I'm able to generate a static site from my nuxt project using
$ npx nuxt generate
我对设置生成的静态文件的输出文件夹感兴趣.
I'm interested in setting the output folder for the generated static files.
我正在阅读 https://nuxtjs.org/api/configuration-generate,这说明我应该看一下generate属性.但是,我不明白如何修改或访问generate属性.我将如何访问generate属性?
I'm reading through https://nuxtjs.org/api/configuration-generate which explains that I should be looking at the generate property. However, I don't understand how to modift or access the generate property. How cam I access the generate property?
编辑;我将nuxt.config.js构建对象更改为:
EDIT; I changed the nuxt.config.js build object to :
build: {
publicPath: 'public/',
/*
** You can extend webpack config here
*/
extend(config, ctx) {
}
}
}
然后跑
$ npx nuxt generate
未生成公用文件夹
推荐答案
在config.exports下的config中使用nuxt.config.js,因此您的生成文件夹将是 my-dist 而不是 dist
use below config into nuxt.config.js under module.exports, So your generate folder will be my-dist instead of dist
module.exports = {
mode: 'spa',
generate: {
dir: 'my-dist'
},
...............
.............
}
,如果您想使用自定义文件夹将所有js,css和assests保留在 dist 文件夹下以进行spa生成,则在配置对象下的nuxt.config.js中使用以下配置
and if you want to use custom folder to keep all js,css and assests under dist folder for spa generate then use below config into nuxt.config.js under build object
publicPath:"public/"
publicPath: 'public/'
示例:
build: {
publicPath: 'public/',
.........
............
}
这篇关于在Nuxt中设置输出文件夹的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!