Skip to content

Commit 9d68d70

Browse files
author
Pooya Parsa
committedNov 16, 2017
fix(icon): generate only on build
1 parent ecaa835 commit 9d68d70

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed
 

Diff for: ‎packages/icon/index.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
const fs = require('fs-extra')
22
const path = require('path')
33
const Jimp = require('jimp')
4+
const debug = require('debug')('nuxt:pwa:icon')
45

56
const fixUrl = url => url.replace(/\/\//g, '/').replace(':/', '://')
67
const isUrl = url => url.indexOf('http') === 0 || url.indexOf('//') === 0
78

89
module.exports = function nuxtIcon (options) {
10+
this.nuxt.plugin('build', builder => {
11+
debug('Generating icons')
12+
generateIcons.call(this, options)
13+
})
14+
}
15+
16+
function generateIcons (options) {
917
const iconSrc = options.iconSrc || path.resolve(this.options.srcDir, 'static', 'icon.png')
1018
const sizes = options.sizes || [64, 120, 144, 152, 192, 384, 512]
1119

@@ -22,7 +30,7 @@ module.exports = function nuxtIcon (options) {
2230
// Ensure icon file exists
2331
if (!fs.existsSync(iconSrc)) {
2432
/* eslint-disable no-console */
25-
console.warn('[@nuxtjs/icon]', path.relative(this.options.srcDir, iconSrc), 'not found! Please create one or disable icon module.')
33+
debug(path.relative(this.options.srcDir, iconSrc), 'not found! Please create one or disable icon module.')
2634
return
2735
}
2836

0 commit comments

Comments
 (0)