Skip to content

Commit

Permalink
refactor: use tapable hooks (#103)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: webpack >= 4 (Nuxt >= 2) is required
  • Loading branch information
manniL authored and pi0 committed Nov 11, 2018
1 parent e9062be commit 9f27d5c
Show file tree
Hide file tree
Showing 4 changed files with 1,484 additions and 6 deletions.
3 changes: 1 addition & 2 deletions packages/icon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,13 @@ function generateIcons (moduleOptions) {
// Register webpack plugin to emit icons
this.options.build.plugins.push({
apply (compiler) {
compiler.plugin('emit', function (compilation, _cb) {
compiler.hooks.emit.tap('nuxt-pwa-icon', compilation => {
icons.forEach(icon => {
compilation.assets[icon.fileName] = {
source: () => icon.buff,
size: () => icon.buff.length
}
})
_cb()
})
}
})
Expand Down
3 changes: 1 addition & 2 deletions packages/manifest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,11 @@ function addManifest (options) {
// Register webpack plugin to emit manifest
this.options.build.plugins.push({
apply (compiler) {
compiler.plugin('emit', function (compilation, cb) {
compiler.hooks.emit.tap('nuxt-pwa-manifest', (compilation) => {
compilation.assets[manifestFileName] = {
source: () => manifestSource,
size: () => manifestSource.length
}
cb()
})
}
})
Expand Down
3 changes: 1 addition & 2 deletions packages/onesignal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,11 @@ function addOneSignal (moduleOptions) {

this.options.build.plugins.push({
apply (compiler) {
compiler.plugin('emit', function (compilation, cb) {
compiler.hooks.emit.tap('nuxt-pwa-onesignal', (compilation) => {
compilation.assets[OneSignalSDKFile] = {
source: () => OneSignalSDKJS,
size: () => OneSignalSDKJS.length
}
cb()
})
}
})
Expand Down
Loading

0 comments on commit 9f27d5c

Please sign in to comment.