From 9d68d70bb8ce5d3f9ef23b98e305e8ac136d8ef2 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Thu, 16 Nov 2017 20:15:36 +0330 Subject: [PATCH] fix(icon): generate only on build --- packages/icon/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/icon/index.js b/packages/icon/index.js index 5f6f29d5..49258bfa 100755 --- a/packages/icon/index.js +++ b/packages/icon/index.js @@ -1,11 +1,19 @@ const fs = require('fs-extra') const path = require('path') const Jimp = require('jimp') +const debug = require('debug')('nuxt:pwa:icon') const fixUrl = url => url.replace(/\/\//g, '/').replace(':/', '://') const isUrl = url => url.indexOf('http') === 0 || url.indexOf('//') === 0 module.exports = function nuxtIcon (options) { + this.nuxt.plugin('build', builder => { + debug('Generating icons') + generateIcons.call(this, options) + }) +} + +function generateIcons (options) { const iconSrc = options.iconSrc || path.resolve(this.options.srcDir, 'static', 'icon.png') const sizes = options.sizes || [64, 120, 144, 152, 192, 384, 512] @@ -22,7 +30,7 @@ module.exports = function nuxtIcon (options) { // Ensure icon file exists if (!fs.existsSync(iconSrc)) { /* eslint-disable no-console */ - console.warn('[@nuxtjs/icon]', path.relative(this.options.srcDir, iconSrc), 'not found! Please create one or disable icon module.') + debug(path.relative(this.options.srcDir, iconSrc), 'not found! Please create one or disable icon module.') return }