Permalink
Browse files

feat(manifest): defaultIcon option

  • Loading branch information...
pi0 committed Jun 5, 2017
1 parent 026985d commit 1086962ec4f90ad4fd88cd799a06917a4ccf1335
Showing with 12 additions and 9 deletions.
  1. +12 −9 modules/manifest/index.js
@@ -5,32 +5,35 @@ const hash = require('hash-sum')
const fixUrl = url => url.replace(/(?!^)\/\//g, '/').replace(':/', '://')// // ~> /
module.exports = function nuxtManifest(options) {
module.exports = function nuxtManifest (options) {
const routerBase = this.options.router.base === '/' ? '' : this.options.router.base
const defaultName = options.name || this.options.manifest.name || process.env.npm_package_name
const defaultShortName = process.env.npm_package_name || defaultName
const defaultIcon = Object.assign({
src: fixUrl(`${routerBase}/icon.png`),
sizes: '512x512',
type: 'image/png'
}, options.defaultIcon, this.options.manifest.defaultIcon)
const defaults = {
name: defaultName,
short_name: defaultShortName,
description: defaultName,
icons: [
{
src: fixUrl(`${routerBase}/icon.png`),
sizes: '512x512',
type: 'image/png'
}
],
icons: [defaultIcon],
start_url: fixUrl(`${routerBase}/`),
display: 'standalone',
background_color: '#ffffff',
theme_color: (this.options.loading && this.options.loading.color) || '#3f51b5',
lang: 'en'
}
// Write manifest.json
// manifest.json
const manifest = _.defaultsDeep({}, options, this.options.manifest, defaults)
// Sanetize
delete manifest.src
delete manifest.defaultIcon
// Write file
const manifestFileName = `manifest.${hash(manifest)}.json`
const distDir = 'static'
const manifestFilePath = path.resolve(this.options.rootDir, distDir, manifestFileName)

0 comments on commit 1086962

Please sign in to comment.