posthtml / posthtml-inline-favicon

PostHTML plugin to inline favicons
MIT License
2 stars 0 forks source link

[q] inline favicon in vite #44

Closed ZuBB closed 7 months ago

ZuBB commented 7 months ago

Hey there!

I need to inline the favicon (PNG image) into a .html file in a project that uses Vite as a bundler.

Right now, I have the next snippet in the config:

...
  const plugins = [
    react(), svgr(), Info(),
    posthtml({
      plugins: [
        inlineFavicon()
      ]
    })
  ];
...

And it does not work.

Here is a source line from my HTML file:

...
    <link rel="icon" type="image/png" sizes="32x32" href="/src/assets/favicon.png">
...

This is what I get in resulted HTML file:

...
    <link rel="icon" type="image/png" sizes="32x32" href="./favicon-Co0w4LGE.png">
...

Any chance you have some ideas/hints on this issue?

Scrum commented 7 months ago

Hi, can you create the simplest example of reproducing this? It is not very clear what kind of configuration you have

ZuBB commented 7 months ago

Ok, I figured out why it did not work for me. It's because the selector needs a shortcut value.

https://github.com/posthtml/posthtml-inline-favicon/blob/8658d2c2553c7ed45ea41fb7aa8e9762d9c585d7/src/inlineFavicon.ts#L8

Accordingly, to mdn, shortcut is an old link type and should not be used.

https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel#sect4

Are you interested in this change? It should not be very hard. I can try to cook a PR with it

metonym commented 7 months ago

@ZuBB A PR would be most welcome, thank you! Maybe rel could just be a RegExp for "icon"

ZuBB commented 7 months ago

Maybe rel could just be a RegExp for "icon"

Yes, that was my plan.

Can we expect a new release after the fix will be applied? If so, can you give an ETA for that?

metonym commented 7 months ago

As soon as it's applied, I'm available to re-publish. Will be around for an hour or so; otherwise, will do so first thing in the morning.

ZuBB commented 7 months ago

As soon as it's applied, I'm available to re-publish. Will be around for an hour or so; otherwise, will do so first thing in the morning.

Great. already working on the change(s)

ZuBB commented 7 months ago

here it is @metonym

https://github.com/posthtml/posthtml-inline-favicon/pull/45

ZuBB commented 7 months ago

Thanks a lot, @metonym, for the quick help.

metonym commented 7 months ago

Released in v0.1.3. Thanks for the fix!