Set path to output folder in Nuxt

梦想的初衷 提交于 2020-02-02 10:07:20

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!