Skip to content

Commit

Permalink
Fix recursive filename after several rebuilds in development
Browse files Browse the repository at this point in the history
Also:
- Fix svg assets not having the correct public url
- Remove debug console.logs from the code

Fixes arthurbergmz#30
  • Loading branch information
satazor committed Feb 13, 2018
1 parent de651b5 commit 55337f9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/icons/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ function processIcon (currentSize, icon, buffer, mimeType, publicPath, shouldFin
const fileName = shouldFingerprint ? `icon_${dimensions}.${generateFingerprint(buffer)}.${mime.extension(mimeType)}` : `icon_${dimensions}.${mime.extension(mimeType)}`
const iconOutputDir = icon.destination ? joinURI(icon.destination, fileName) : fileName
const iconPublicUrl = joinURI(publicPath, iconOutputDir)
console.log('webpackAsset.color', icon.color)
return {
manifestIcon: {
src: iconPublicUrl,
Expand All @@ -40,6 +39,7 @@ function processIcon (currentSize, icon, buffer, mimeType, publicPath, shouldFin
},
webpackAsset: {
output: iconOutputDir,
url: iconPublicUrl,
source: buffer,
size: buffer.length,
ios: icon.ios ? { valid: icon.ios, size: dimensions, href: iconPublicUrl } : false,
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class WebpackPwaManifest {
if (themeColorTag.content) applyTag(tags, 'meta', themeColorTag)
applyTag(tags, 'link', {
rel: 'manifest',
href: that.options.filename
href: that.manifest.url,
})
tags = generateMaskIconLink(tags, that.assets)
htmlPluginData.html = htmlPluginData.html.replace(/(<\/head>)/i, `${generateHtmlTags(tags)}</head>`)
Expand Down
8 changes: 4 additions & 4 deletions src/injector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function manifest (options, publicPath, icons, callback) {
const output = options.includeDirectory ? path.join(file.dir, filename) : filename
callback(null, {
output,
file: joinURI(publicPath, output),
url: joinURI(publicPath, output),
source: json,
size: json.length
})
Expand All @@ -72,7 +72,8 @@ export function buildResources (_this, publicPath, callback) {
if (err) return
manifest(_this.options, publicPath, result.icons, (fail, manifest) => {
if (fail) return
_this.options.filename = manifest.file
_this.options.filename = manifest.output
_this.manifest = manifest;
_this.assets = [manifest, ...(result.assets || [])]
callback()
})
Expand Down Expand Up @@ -130,10 +131,9 @@ export function generateAppleTags (options, assets) {
export function generateMaskIconLink(tags, assets) {
const svgAsset = assets.find((asset) => /[^.]+$/.exec(asset.output)[0] === 'svg')
if (svgAsset) {
console.log('svgAsset.color', svgAsset.color)
applyTag(tags, 'link', Object.assign({
rel: 'mask-icon',
href: svgAsset.output
href: svgAsset.url
}, !!svgAsset.color && { color: svgAsset.color }))
}
return tags
Expand Down
2 changes: 1 addition & 1 deletion tests/basic/test/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html><head><meta charset=UTF-8><title>Webpack App</title><meta name=apple-mobile-web-app-title content="My Progressive Web App"><meta name=apple-mobile-web-app-capable content=yes><meta name=apple-mobile-web-app-status-bar-style content=default><link rel=apple-touch-icon sizes=1024x1024 href=/icons/icon_1024x1024.9e29ee0667fc45a8662544c71ddd52ad.png><link rel=manifest href=/manifest.b1d5584834886e9dc1416477ace128de.json><link rel=mask-icon href=icons/icon_512x512.dd60b11e9762b6e25f6d4ce981a1eeae.svg color=#ffffff></head><body></body></html>
<!DOCTYPE html><html><head><meta charset=UTF-8><title>Webpack App</title><meta name=apple-mobile-web-app-title content="My Progressive Web App"><meta name=apple-mobile-web-app-capable content=yes><meta name=apple-mobile-web-app-status-bar-style content=default><link rel=apple-touch-icon sizes=1024x1024 href=/icons/icon_1024x1024.9e29ee0667fc45a8662544c71ddd52ad.png><link rel=manifest href=/manifest.b1d5584834886e9dc1416477ace128de.json><link rel=mask-icon href=/icons/icon_512x512.dd60b11e9762b6e25f6d4ce981a1eeae.svg color=#ffffff></head><body></body></html>

0 comments on commit 55337f9

Please sign in to comment.