Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set path to output folder in Nuxt

enter image description here

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

like image 640
user1592380 Avatar asked Jan 01 '23 09:01

user1592380


1 Answers

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/',
.........
............
}
like image 129
Mahamudul Hasan Avatar answered Jan 08 '23 13:01

Mahamudul Hasan