Permalink
Browse files

fix(icon): generate only on build

  • Loading branch information...
pi0 committed Nov 16, 2017
1 parent ecaa835 commit 9d68d70bb8ce5d3f9ef23b98e305e8ac136d8ef2
Showing with 9 additions and 1 deletion.
  1. +9 −1 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
}

0 comments on commit 9d68d70

Please sign in to comment.