问题
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.
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?
EDIT; I changed the nuxt.config.js build object to :
build: {
publicPath: 'public/',
/*
** You can extend webpack config here
*/
extend(config, ctx) {
}
}
}
Then ran
$ npx nuxt generate
No public folder is generated
回答1:
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'
},
...............
.............
}
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/'
example:
build: {
publicPath: 'public/',
.........
............
}
来源:https://stackoverflow.com/questions/54380719/set-path-to-output-folder-in-nuxt