Nuxt instance in Module is undefined nuxt3 stable

In RC 13 I could access the this.nuxt property. But now the same "this" call is undefined. Does anyone know how to call access the Nuxt property to setup a hook? ~/modules/material-design-icons
import { resolve } from 'path'

const icons = ["ChevronRight", "ChevronDown"];

export default function () {
this.nuxt.hook("components:dirs", (dirs) => {
dirs.push({
path: resolve("node_modules/vue-material-design-icons"),
prefix: "MaterialIcon",
pattern: `**/@(${icons.join("|")}).vue`
});
});
}
import { resolve } from 'path'

const icons = ["ChevronRight", "ChevronDown"];

export default function () {
this.nuxt.hook("components:dirs", (dirs) => {
dirs.push({
path: resolve("node_modules/vue-material-design-icons"),
prefix: "MaterialIcon",
pattern: `**/@(${icons.join("|")}).vue`
});
});
}
2 Replies
ILLuMiNaTe
ILLuMiNaTeOP2y ago
Apparently there is defineNuxtModule now!
import { resolve } from 'path'
import { defineNuxtModule } from '@nuxt/kit'

const icons = ['ChevronRight', 'ChevronDown']

const module = defineNuxtModule({
async setup(options, nuxt) {
nuxt.hook('components:dirs', (dirs) => {
dirs.push({
path: resolve('node_modules/vue-material-design-icons'),
prefix: 'MaterialIcon',
pattern: `**/@(${icons.join('|')}).vue`
})
})
}
})

export { module as default }
import { resolve } from 'path'
import { defineNuxtModule } from '@nuxt/kit'

const icons = ['ChevronRight', 'ChevronDown']

const module = defineNuxtModule({
async setup(options, nuxt) {
nuxt.hook('components:dirs', (dirs) => {
dirs.push({
path: resolve('node_modules/vue-material-design-icons'),
prefix: 'MaterialIcon',
pattern: `**/@(${icons.join('|')}).vue`
})
})
}
})

export { module as default }
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server