Quentin
Quentin
NNuxt
Created by Quentin on 11/6/2024 in #❓・help
components configuration in layers
I logged components:dir hook parameter and the declaration for ./components was duplicated, first without pathPrefix option and at the end of the array with what i wrote in the layer confg, so prefix set to false. I don't know where i read that but earlier definitions in components array take priority, so redefining something in layer configuration will never work. I managed to do what i want with this nuxt.config.ts in a layer :
import path from 'path'

export default defineNuxtConfig({
hooks: {
'components:dirs': (componentsDirs) => {
const component = componentsDirs.find(componentDir => componentDir.path === path.resolve(__dirname, '../../components'))

if (component) component.pathPrefix = false
},
},
})
import path from 'path'

export default defineNuxtConfig({
hooks: {
'components:dirs': (componentsDirs) => {
const component = componentsDirs.find(componentDir => componentDir.path === path.resolve(__dirname, '../../components'))

if (component) component.pathPrefix = false
},
},
})
6 replies