Skip to content

Commit

Permalink
chore: only support nuxt.hook
Browse files Browse the repository at this point in the history
BREAKING CHANGE: needs nuxt 2.x or later
  • Loading branch information
pi0 committed Dec 12, 2018
1 parent d4e8e3f commit 854d826
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/icon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = function nuxtIcon (options) {
return hook()
}

this.nuxt.hook ? this.nuxt.hook('build:before', hook) : this.nuxt.plugin('build', hook)
this.nuxt.hook('build:before', hook)
}

function generateIcons (moduleOptions) {
Expand Down
2 changes: 1 addition & 1 deletion packages/manifest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = function nuxtManifest (options) {
return hook()
}

this.nuxt.hook ? this.nuxt.hook('build:before', hook) : this.nuxt.plugin('build', hook)
this.nuxt.hook('build:before', hook)
}

function addManifest (options) {
Expand Down
2 changes: 1 addition & 1 deletion packages/meta/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = function nuxtMeta (_options) {
return hook()
}

this.nuxt.hook ? this.nuxt.hook('build:before', hook) : this.nuxt.plugin('build', hook)
this.nuxt.hook('build:before', hook)
}

function generateMeta (_options) {
Expand Down
2 changes: 1 addition & 1 deletion packages/onesignal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = function nuxtOneSignal (moduleOptions) {
return hook()
}

this.nuxt.hook ? this.nuxt.hook('build:before', hook) : this.nuxt.plugin('build', hook)
this.nuxt.hook('build:before', hook)
}

// =============================================
Expand Down
18 changes: 3 additions & 15 deletions packages/workbox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module.exports = function nuxtWorkbox (moduleOptions) {
}
})

this.nuxt.hook ? this.nuxt.hook('build:before', hook) : this.nuxt.plugin('build', hook)
this.nuxt.hook('build:before', hook)
}

// =============================================
Expand Down Expand Up @@ -198,13 +198,7 @@ function emitAssets (options) {
})
}

if (this.nuxt.hook) {
this.nuxt.hook('build:done', hook)
} else {
this.nuxt.plugin('build', builder => {
builder.plugin('built', hook)
})
}
this.nuxt.hook('build:done', hook)

// workbox.js
let wbPath = require.resolve('workbox-sw')
Expand All @@ -227,13 +221,7 @@ function workboxInject (options) {
return swBuild.injectManifest(opts)
}

if (this.nuxt.hook) {
this.nuxt.hook('build:done', hook)
} else {
this.nuxt.plugin('build', builder => {
builder.plugin('built', hook)
})
}
this.nuxt.hook('build:done', hook)
}

// =============================================
Expand Down

0 comments on commit 854d826

Please sign in to comment.