Skip to content

Fix favicon links to use paths instead of embedded data.#8961

Merged
cjcenizal merged 5 commits intoelastic:masterfrom
cjcenizal:bug/embedded-favicons
Nov 15, 2016
Merged

Fix favicon links to use paths instead of embedded data.#8961
cjcenizal merged 5 commits intoelastic:masterfrom
cjcenizal:bug/embedded-favicons

Conversation

@cjcenizal
Copy link
Contributor

I originally noticed a problem when I saw that the manifest.json file was being embedded as a JS object. This solution fixes that problem, and additionally sets each href to be a link to the asset instead of the embedded asset.

@cjcenizal cjcenizal added bug Fixes for quality problems that affect the customer experience v5.0.1 v5.1.0 v6.0.0 labels Nov 3, 2016
Copy link
Member

@tylersmalley tylersmalley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@trevan
Copy link
Contributor

trevan commented Nov 4, 2016

I think you'll need to update the locations in the manifest.json. They need to point to where webpack outputs the images (https://developer.mozilla.org/en-US/docs/Web/Manifest).

@cjcenizal
Copy link
Contributor Author

Great catch @trevan! Thanks!

@tylersmalley
Copy link
Member

We can actually move the assets to kibana/src/core_plugins/kibana/public/assets/ which is mapped to /plugins/kibana/assets/. My only question would be how to dynamically handle basePath in the JSON file.

@cjcenizal
Copy link
Contributor Author

@tylersmalley @trevan Ready for another look, thanks!

@LeeDr LeeDr added v5.0.2 and removed v5.0.1 labels Nov 4, 2016
@epixa epixa added the review label Nov 15, 2016
@cjcenizal cjcenizal force-pushed the bug/embedded-favicons branch from 6292aa3 to 83b2a78 Compare November 15, 2016 20:42
* Serve favicons directly from ui directory, using exposeStaticDir.
@cjcenizal cjcenizal force-pushed the bug/embedded-favicons branch from 83b2a78 to 6b1a99b Compare November 15, 2016 20:43
@tylersmalley
Copy link
Member

android-chrome-256x256.png looks pretty blown out, do we have a higher quality version available?

Copy link
Contributor

@spalger spalger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm good with this because it's probably best that the favicons load immediately, rather than waiting for the js assets.

I'd like to point out though; this could be accomplished with webpack and would reduce the spread of favicon-related logic around the source.

If you don't want a file to be inlined in the bundle, or returned as a json object, just prefix the require statement with !file!.

require('!file!./favicon.ico') // loader override with relative path

The ! syntax is webpack's, and tells it to disable the default loaders and only use the file loader. By default this loader will resolve the require statement with a URL to the required asset that automatically adjusts to basePath and includes the hash of the content for ultimate cache busting.

Here is an example of using this strategy, in case you're interested: https://gist.github.com/spalger/371ebce6782e8335472dc66410ee1307

@cjcenizal
Copy link
Contributor Author

@spalger Thanks man! That's how I originally implemented it in this PR: 5a88701

I decided against this because I think we should solve the problem of "serving static assets" in the same way, wherever possible, to make our code more predictable. I think @tylersmalley has some thoughts about how to improve this in the future.

@tylersmalley
Copy link
Member

The main reason for this approach was because we needed to define the path in the manifest.json, which is based on the basePath.

I just did some testing in the Android Emulator to verify this PR functionally works. In addition, I tested setting the icon source to be relative, which worked. Considering that is the case, I think it would be best to go back to the static asset and remove the route.

screenshot 2016-11-15 15 19 35

Thoughts?

@tylersmalley
Copy link
Member

This LGTM. Another benefit of not having it bundled inline is the reduced bundle size since these assets are primarily browser specific.

@spalger
Copy link
Contributor

spalger commented Nov 15, 2016

LGTM

@cjcenizal cjcenizal merged commit 054e9b1 into elastic:master Nov 15, 2016
@cjcenizal cjcenizal deleted the bug/embedded-favicons branch November 15, 2016 23:49
cjcenizal added a commit to cjcenizal/kibana that referenced this pull request Nov 15, 2016
* Move favicon files to ui/public/assets/favicons dir.
* Serve favicons statically from ui directory, using exposeStaticDir.
cjcenizal added a commit that referenced this pull request Nov 16, 2016
* Move favicon files to ui/public/assets/favicons dir.
* Serve favicons statically from ui directory, using exposeStaticDir.
cjcenizal added a commit to cjcenizal/kibana that referenced this pull request Nov 16, 2016
* Move favicon files to ui/public/assets/favicons dir.
* Serve favicons statically from ui directory, using exposeStaticDir.
cjcenizal added a commit that referenced this pull request Nov 16, 2016
* Move favicon files to ui/public/assets/favicons dir.
* Serve favicons statically from ui directory, using exposeStaticDir.
@epixa epixa added v5.1.1 and removed v5.1.0 labels Dec 8, 2016
airow pushed a commit to airow/kibana that referenced this pull request Feb 16, 2017
… (elastic#9092)

* Move favicon files to ui/public/assets/favicons dir.
* Serve favicons statically from ui directory, using exposeStaticDir.

Former-commit-id: 3396233
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Fixes for quality problems that affect the customer experience review v5.0.2 v5.1.1 v6.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants