Skip to content

Commit

Permalink
fix(icon): generate only on build
Browse files Browse the repository at this point in the history
  • Loading branch information
Pooya Parsa committed Nov 16, 2017
1 parent ecaa835 commit 9d68d70
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/icon/index.js
Original file line number Diff line number Diff line change
@@ -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]

Expand All @@ -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
}

Expand Down

0 comments on commit 9d68d70

Please sign in to comment.