question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issues with relative icon-paths

See original GitHub issue

Hi! First, thanks for this truly awesome plugin! It simplifies a lot 😃

The problem

If a webapp is deployed in a relative, unknown directory a few problems pop up with the url of each icon in the manifest.json file. Let’s consider the following dir-structure, ? being an unknown parent-url.

/?/index.html
/?/assets/manifest.json
/?/assets/icon.ico

The manifest contains, considering publicPath: '.' and prefix: './assets', now url such as

"src": "assets/android-chrome-36x36.png"

Since assets/ is a relative url the location of the maifest is used:

The path to the image file. If src is a relative URL, the base URL will be the URL of the manifest.

That means the url to each icon is not longer valid (resolved url):

assets/assets/android-chrome-36x36.png

The first assets is the location of the manifest.json whereby the second assets was used to define a sub-directory in the build-directory.

A solution is to set prefix to ./, but this causes all assets to be moved into the root-folder. The urls in the HTML-Header itself are always valid as the current index.html url is used as reference.

Used packages

I’m using

  • webpack v4.42.0
  • favicons-webpack-plugin v3.0.1
  • html-webpack-plugin v4.0.0-beta.14

Steps to reproduce

It might be related to #162

Relevant FaviconsWebpackPlugin config, I’m referring to webpack in production mode:

    publicPath: '.',
    prefix: './assets',
    favicons: {start_url: './?homescreen=1'}

Build the dist-files, serve the parent-folder and manually navigate into the dist-folder. In my case these are the related requests and the last one which fails:

OK: http://localhost:5000/dist/index.html (Entry)
OK: http://localhost:5000/dist/assets/favicon.ico
OK: http://localhost:5000/dist/assets/manifest.json (The location of manifest.json is /assets!)
ERR: http://localhost:5000/dist/assets/assets/android-chrome-144x144.png (404)

A possible fix would be to remove the prefix from each icon in the manifest entirely as long as they’re in the same location as manifest.json and publicPath is relative. index.html requires the assets/ -> index.html used as reference manifest.json not as icons are in the same location and the manifest itself is used as reference.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
e-melnichenkocommented, Mar 19, 2020

I used manifestRelativePaths: true in my case.

new FaviconsWebpackPlugin({
   logo: './src/img/favicon-512x512.png',
   publicPath: '',
   favicons: {
    manifestRelativePaths: true,
   }
 })
1reaction
Simonwepcommented, Mar 19, 2020

@e-melnichenko Nice. Wasted like 20h trying to fix that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Relative icon paths do not work · Issue #197 - GitHub
The problem lies with the jpm module, for some reason it is adding the relative icon paths to the rdf file even if...
Read more >
relative icon paths for PhoneGap Build and CLI - Stack Overflow
Has anyone found a way around this issue, so that both local and PhoneGap Build - generated apps have the icons they need?...
Read more >
Broken relative marker icon path [#2941285] | Drupal.org
Okay I found the issue: on display settings and form display settings to get custom markers visible you have to use absolute paths....
Read more >
1125793 - handle relative icon paths in open search providers
Hi, I think that this bug has been fixed. If I'm mistaken, please reopen it. Regards, Flor. Status: NEW → RESOLVED. Closed: 1 ......
Read more >
Ticket #1903: Incorrect icon paths in Window.js - Xpra
We changed to use relative urls to handle non-standard paths. I don't understand why relative paths would not work here. Can you provide...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found