所有模块都将在ModuleContainer实例的context调用。
我们可以在某些生命周期事件中注册hooks。
nuxt.moduleContainer.plugin(ready, async (moduleContainer) => {
// Do this after all modules where ready
})
在 modules 的context中我们可以使用它:
this.plugin(ready, async (moduleContainer) => {
// Do this after all modules where ready
})
插件 | 参数 | 说明 |
---|---|---|
ready | moduleContainer | nuxt.config.js 中的所有模块都已初始化 |
vendor已经废弃不再使用
添加到options.build.vendor并应用唯一插件过滤器。
在构建到项目buildDir (.nuxt)期间使用lodash 模板渲染指定模板。
如果未提供fileName或template为string,则目标文件名默认为[dirName].[fileName].[pathHash].[ext]。
这个方法将返回 { dist, src, options } 对象.
使用addTemplate注册插件并将其添加到 plugins[]选项。
您可以使用template.ssr: false来禁用包含在SSR中的插件。
将中间件插入 options.serverMiddleware.
Allows easily extending webpack build config by chaining options.build.extend function.
允许通过链接options.build.extendRoutes函数轻松扩展webpack构建配置。
注册模块。moduleOpts可以是string或[src, options]。如果requireOnce为true且已解析的模块导出meta阻止两次注册相同的模块。
addModule(moduleOpts, true)
我们可以在某些生命周期事件中注册钩子。
Hook | Arguments | When |
---|---|---|
modules:before | (moduleContainer, options) | 在创建ModuleContainer类之前调用,对重载方法和选项很有用。 |
modules:done | (moduleContainer) | 加载所有模块时调用。 |