If you need to do certain tasks on a specific life cycle event (for example, when all modules have finished loading) when Nuxt is being booted, you can create a module and use the hook method to listen on that event and then do the task. Consider the following examples:
- If you want to do something when all modules have finished loading, try the following:
export default function (moduleOptions) {
this.nuxt.hook('modules:done', moduleContainer => {
//...
})
}
- If you want to do something after the renderer has been created, try the following:
export default function (moduleOptions) {
this.nuxt.hook('render:before', renderer => {
//...
})
}
- If you want to do something before the compiler (webpack is the default) starts, try the following:
export default function (moduleOptions) {
this.nuxt.hook('build:compile', async ({ name, compiler }) => {
//...
})
}
- If you want to do something before Nuxt generates...