From a0fb9084462d5f212009ec80cf0c64142ff59126 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Fri, 17 Nov 2017 14:39:44 +0330 Subject: [PATCH] fix: workaround to fill meta with SPA and nuxt start --- packages/icon/index.js | 6 +++++- packages/manifest/index.js | 6 +++++- packages/meta/index.js | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/icon/index.js b/packages/icon/index.js index 7744b172..7149b177 100755 --- a/packages/icon/index.js +++ b/packages/icon/index.js @@ -7,11 +7,15 @@ const fixUrl = url => url.replace(/\/\//g, '/').replace(':/', '://') const isUrl = url => url.indexOf('http') === 0 || url.indexOf('//') === 0 module.exports = function nuxtIcon (options) { - const hook = builder => { + const hook = () => { debug('Adding icons') return generateIcons.call(this, options) } + if (this.options.mode === 'spa') { + return hook() + } + this.nuxt.hook ? this.nuxt.hook('build:before', hook) : this.nuxt.plugin('build', hook) } diff --git a/packages/manifest/index.js b/packages/manifest/index.js index d8c661ec..5a17676a 100755 --- a/packages/manifest/index.js +++ b/packages/manifest/index.js @@ -6,11 +6,15 @@ const isUrl = url => url.indexOf('http') === 0 || url.indexOf('//') === 0 const find = (arr, key, val) => arr.find(obj => val ? obj[key] === val : obj[key]) module.exports = function nuxtManifest (options) { - const hook = builder => { + const hook = () => { debug('Adding manifest') addManifest.call(this, options) } + if (this.options.mode === 'spa') { + return hook() + } + this.nuxt.hook ? this.nuxt.hook('build:before', hook) : this.nuxt.plugin('build', hook) } diff --git a/packages/meta/index.js b/packages/meta/index.js index 6dd9b98b..6beed2b2 100755 --- a/packages/meta/index.js +++ b/packages/meta/index.js @@ -3,11 +3,15 @@ const debug = require('debug')('nuxt:pwa') const find = (arr, key, val) => arr.find(obj => val ? obj[key] === val : obj[key]) module.exports = function nuxtMeta (_options) { - const hook = builder => { + const hook = () => { debug('Adding meta') generateMeta.call(this, _options) } + if (this.options.mode === 'spa') { + return hook() + } + this.nuxt.hook ? this.nuxt.hook('build:before', hook) : this.nuxt.plugin('build', hook) }