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.

[5.0.0-alpha.11] building more than one set of favicons (webpack 5)

See original GitHub issue

Hello, I’m having issue generating more than one set of favicons.

My use case is that I need to build public/en-us/favicon.svg and public/en-gb/favicon.svg. When I was using webpack 4, I used to be able to create two instances of the plugin like this:

// webpack.config.js
plugins: [
  new HtmlWebpackPlugin({
    template: "./public/index.html",
  }),
  new FaviconsWebpackPlugin({
    logo: "./public/en-us/favicon.svg",
    prefix: "assets/en-us",
    inject: false,
  }),
  new FaviconsWebpackPlugin({
    logo: "./public/en-gb/favicon.svg",
    prefix: "assets/en-gb",
    inject: false,
  }),
]

The build used to output two separate folders, dist/assets/en-us and dist/assets/en-gb as expected. After I migrated to webpack 5, it seems like the last entry in the plugin array (en-gb) is the only one that is being created.

Setup to reproduce the issue

    "devDependencies": {
        "favicons": "^6.2.0",
        "favicons-webpack-plugin": "^5.0.0-alpha.11",
        "file-loader": "^6.2.0",
        "html-webpack-plugin": "^5.0.0-beta.6",
        "imagemin-svgo": "^8.0.0",
        "imagemin-webpack": "^5.1.1",
        "url-loader": "^4.1.1",
        "webpack": "^5.18.0",
        "webpack-cli": "^3.3.12",
    },
// extract of webpack.config.js
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const FaviconsWebpackPlugin = require("favicons-webpack-plugin");

module.exports = (env, argv) => {
	const { mode } = argv;
	const isDevelopment = mode === "development";
	const isProduction = mode === "production";

	return {
		entry: ["./src/index.js"],
		mode,
		output: {
			path: path.resolve(__dirname, "dist"),
			publicPath: "/",
			filename: isProduction ? "[name].[chunkhash].js" : "[name].js",
		},
		optimization: {
			// ...
		},
		module: {
			rules: [
				{
					test: /\.(jpe?g|png|webp|gif|svg|ico)$/i,
					use: [
						{
							loader: "file-loader",
							options: {
								outputPath: "assets",
							},
						},
					],
				},
			],
		},
		plugins: [
			new HtmlWebpackPlugin({
				template: "./public/index.html",
			}),
			new FaviconsWebpackPlugin({
				logo: "./public/en-us/favicon.svg",
				prefix: "assets/en-us",
				inject: false,
			}),
			new FaviconsWebpackPlugin({
				logo: "./public/en-gb/favicon.svg",
				prefix: "assets/en-gb",
				inject: false,
			}),
		].filter(Boolean),
	};
};

I’m also seeing this message when running webpack, not sure if it’s related or not:

(node:13384) [DEP_WEBPACK_COMPILATION_ASSETS] DeprecationWarning: Compilation.assets will be frozen in future, all modifications are deprecated.
BREAKING CHANGE: No more changes should happen to Compilation.assets after sealing the Compilation.
        Do changes to assets earlier, e. g. in Compilation.hooks.processAssets.
        Make sure to select an appropriate stage from Compilation.PROCESS_ASSETS_STAGE_*.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
rbellingcommented, Jan 29, 2021

works like a charm @jantimon 🥳 🎈

Thank you for responding so quickly, amazing work on this project.

1reaction
jantimoncommented, Jan 29, 2021

can you please try favicons-webpack-plugin@5.0.0-alpha.12 ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Support Webpack 5 · Issue #222 · jantimon/favicons ... - GitHub
I'm using yarn 1.22.10 and 5.0.0-alpha.11 of favicons-webpack-plugin. And also just in case, webpack 5.18.
Read more >
favicons-webpack-plugin - npm
Let webpack generate all your favicons and icons for you. Latest version: 6.0.0, last published: a month ago.
Read more >
favicons-webpack-plugin/CHANGELOG.md - UNPKG
41, * allow compiling multiple icon sets ([03c3514](https://github.com/jantimon/favicons-webpack-plugin/commit/03c351434600c5f8eded4757f3efa9f728cd0de1)).
Read more >
FaviconsWebpackPlugin: outputting without injection?
html-webpack-plugin has an option for favicon which then will be available in htmlWebpackPlugin.files object as favicon key.
Read more >
Html-webpack-plugin NPM
Check Html-webpack-plugin 5.5.0 package - Last release 5.5.0 with MIT licence ... If you have multiple webpack entry points, they will all be...
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