diff --git a/lib/core/nuxt.js b/lib/core/nuxt.js index e418db59c4..5ba85a2958 100644 --- a/lib/core/nuxt.js +++ b/lib/core/nuxt.js @@ -58,6 +58,26 @@ export default class Nuxt { return this } + plugin(name, fn) { + // eslint-disable-next-line no-console + console.error(`[warn] nuxt.plugin('${name}',..) is deprecated. Please use new hooks system.`) + + // A tiny backward compatibility util + const hookMap = { + 'ready': 'ready', + 'close': 'close', + 'listen': 'listen', + 'built': 'build:done' + } + + if (hookMap[name]) { + this.hook(hookMap[name], fn) + } + + // Always return nuxt class which has plugin() for two level hooks + return this + } + hook(name, fn) { if (!name || typeof fn !== 'function') { return