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

Latest release 5.6.2 breaks webpack-favicons #1866

Closed
aleho opened this issue Oct 21, 2024 · 3 comments · Fixed by #1867
Closed

Latest release 5.6.2 breaks webpack-favicons #1866

aleho opened this issue Oct 21, 2024 · 3 comments · Fixed by #1867

Comments

@aleho
Copy link

aleho commented Oct 21, 2024

The latest release broke webpack-favicons output for me.

Current behaviour 💣

With the example below on version 5.6.2 html/favicons.html will look like this:

<script defer src="/build/build_name/app/runtime.js"></script><script defer src="/build/build_name/app/app.js"></script><link href="/bu
ild/build_name/app/app.css" rel="stylesheet">

Expected behaviour ☀️

On version 5.6.0 it looked like this:

<link rel="shortcut icon" href="/build/build_name/app/favicons/favicon.ico"><link rel="icon" type="image/png" sizes="16x16" href="/b
uild/build_name/app/favicons/favicon-16x16.png"><link rel="icon" type="image/png" sizes="32x32" href="/build/build_name/app/favicons/fa
vicon-32x32.png"><link rel="icon" type="image/png" sizes="48x48" href="/build/build_name/app/favicons/favicon-48x48.png"><script def
er src="/build/build_name/app/runtime.js"></script><script defer src="/build/build_name/app/app.js"></script><link href="/build/build_name
/app/app.css" rel="stylesheet">

Reproduction Example 👾

Using the following template and configuration:

<%= htmlWebpackPlugin.tags.headTags %>
<%= htmlWebpackPlugin.tags.bodyTags %>
new HtmlWebpackPlugin({
    template: 'html.tmpl',
    filename: 'html/favicons.html',
    minify:   false,
    inject:   false,
})

new WebpackFavicons({
    src:  'favicon.svg',
    path: 'favicons',
    icons: {
        favicons: true
    },
})

Environment 🖥

Node.js v20.17.0
linux 6.11.3-200.fc40.x86_64
Npm 10.9.0
[email protected]
[email protected]
@alexander-akait
Copy link
Collaborator

Could you create a reproducible repository using github?

@alexander-akait
Copy link
Collaborator

Found the problem - https://github.com/drolsen/webpack-favicons/blob/master/index.js#L78

Now:

require('html-webpack-plugin/lib/hooks').getHtmlWebpackPluginHooks(compilation).alterAssetTags.tapAsync(

How to fix:

require('html-webpack-plugin').getCompilationHooks(compilation).alterAssetTags.tapAsync(

html-webpack-plugin/lib/hooks' is a module which has never been public and using it in this way is very dangerous, as the project structure may change

There is a fix - #1867, but I would recommend raising the issue in webpack-favicons, because it will stop working in the next major religion

@aleho
Copy link
Author

aleho commented Oct 23, 2024

Thank you very much! I opened an issue in webpack-favicons as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants