How can I change the name of the _nuxt folder?
Asked Answered
V

3

5

Hello I've got an issue with a Nuxt.js app that I can't seem to resolve. What I want to do is to change the name of the generated _nuxt folder with some other name. So far I've updated the nuxt.config.js and added this snippet:

build: { publicPath: '/new-folder' },

as far as I understand this publicPath variable expects a CDN link so probably this is not the correct way of changing the default _nuxt folder name.

I have also tried adding the buildDir: 'new-folder but when I run the build command it doesn't show up in the project. No matter what changes I added in the nuxt.config file when I deployed it on heroku all the assets where still in the _nuxt folder which causes issues to my project. Am I not seeing something am I doing something wrong?

Venal answered 24/2, 2020 at 11:29 Comment(1)
are you using universal or spa mode?Desultory
D
8

Since the default answer in nuxt JS Documentation is /_nuxt/. The correct answer should be /yourCustomName/ - be ware that you need two forward slash.

In nuxt.config.js

build: {
  publicPath: '/customName/'
}
Durango answered 5/1, 2021 at 13:15 Comment(1)
this is the same I have answered, months before, and 1 negative vote...Anthropogeography
A
2

t's simple, just change in build the publicPath. buildDir is to change the folder for development, where the files will be when coding

nuxt.config.js:

build: {
    publicPath: 'new-folder/',
},

in my case, my publicPath is leo/ enter image description here

you can check more about it here: https://medium.com/@andrejsabrickis/how-to-set-custom-configuration-for-nuxt-js-generate-task-5055e53c2da5

Anthropogeography answered 27/11, 2020 at 16:57 Comment(0)
T
0

For Nuxt3, at nuxt.config.ts, try:

    app: {
        buildAssetsDir: 'folder-here',
    },
Thorite answered 11/12, 2023 at 8:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.