Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Files specified as 'favicon' should use whatever loaders are configured for that filetype #1079

Closed
edmorley opened this issue Oct 15, 2018 · 3 comments
Labels

Comments

@edmorley
Copy link
Contributor

edmorley commented Oct 15, 2018

Is your feature request related to a problem? Please describe.
html-webpack-plugin supports setting a favicon using the favicon option. However setting that to the path to a file, results in it being copied to the output directory as-is, with no opportunity to customise any of:

  • the output filename (eg adding a hash) or location (eg to put under an assets/ subdirectory)
  • whether the icon is inlined or not

Describe the solution you'd like
It seems a simpler way to achieve the above than adding custom support (eg #986 or similar), would be to run the file specified under favicon through whatever webpack loader has been configured for that filetype.

That way users can say configure url-loader for *.ico in their webpack config as normal, setting the name and inline limit as desired, and html-webpack-plugin wouldn't have to handle the addFileToAssets() at all.

This would be similar to what html-loader does itself -- if it discovers resources in the HTML, it defers to whatever loaders are configured for them.

Describe alternatives you've considered

Additional context
See also #364.

@jantimon
Copy link
Owner

Hey @edmorley

I thought many times about a good favicon integration.

Using a loader from a plugin requires a child compiler (which has performance impacts).
So I moved the favicons over to the favicons webpack plugin and I believe that it is still a good idea.

Unfortunately favicons requirements change over and over and over again because of new devices getting launched and new features are getting available.

So maintaining the plugin is very very time consuming and I can't handle it right now.
I have a roadmap for it but I would need help for that.

@glen-84
Copy link

glen-84 commented Feb 8, 2019

If you're using an HTML template and the HTML loader, then you can configure the HTML loader to process link HREFs:

{
    test: /\.html$/,
    use: [
        {
            loader: "html-loader",
            options: {
                attrs: ["img:src", "link:href"] // <-- Here.
            }
        }
    ]
}

... and then add the favicon to your template:

<link rel="icon" type="image/x-icon" href="path/to/favicon.ico" sizes="16x16 32x32" />

Which will output:

<link rel="icon" type="image/x-icon" href="/path/to/favicon-08b6ed97.ico" sizes="16x16 32x32" />

I think that this is actually better than configuring the favicon path in webpack.config.js.

@stale
Copy link

stale bot commented Aug 7, 2019

This issue had no activity for at least half a year. It's subject to automatic issue closing if there is no activity in the next 15 days.

@stale stale bot added the wontfix label Aug 7, 2019
@stale stale bot closed this as completed Aug 22, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Sep 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants