API: The ModuleContainer Class
- Source: core/module.js
We can register hooks on certain life cycle events.
Inside context we can use this instead:
// Do this after all modules where ready
})
Deprecated as vendor
isn't used anymore
Adds to options.build.vendor
and apply unique filter.
addTemplate (template)
- template:
String
orObject
options
fileName
Renders given template using during build into project buildDir
(.nuxt
).
This method returns final { dist, src, options }
object.
addPlugin (template)
Registers a plugin using addTemplate
and adds it to first of option.
You can use template.ssr: false
to disable plugin including in SSR bundle.
Pushes middleware into .
extendBuild (fn)
Allows easily extending webpack build config by chaining function.
extendRoutes (fn)
Allows easily extending plugins by chaining function.
addModule (moduleOpts, requireOnce)
Async function
Registers a module. moduleOpts
can be a string or an array ([src, options]
). If requireOnce
is true
and the resolved module exports meta
, it prevents registering same module twice.
requireModule (moduleOpts)
Async function
Is a shortcut for addModule(moduleOpts, true)
Hook | Arguments | When |
---|---|---|
modules:before | (moduleContainer, options) | Called before creating ModuleContainer class, useful to overload methods and options. |
modules:done | (moduleContainer) | Called when all modules have been loaded. |