Replies: 2 comments 3 replies
-
|
The plugin uses the Favicons generator for Node.js. The |
Beta Was this translation helpful? Give feedback.
-
|
I see, its hard to dig through other plugins source code so I tried writing my own small easy plugin for overwriting the files with correct path. I am going to leave it here, just in case someone else experiences same issue. Resource used: Plugin to adjust paths of manifest files: const path = require('path');
const { FaviconsBundlerPlugin } = require('html-bundler-webpack-plugin/plugins');
class AdjustFaviconManifestPathsPlugin {
constructor(options = {}) {
this.extensionsToAdjustOutputPath = options.extensionsToAdjustOutputPath || [];
}
apply(compiler) {
compiler.hooks.emit.tapAsync('AdjustFaviconManifestPathsPlugin', (compilation, callback) => {
const faviconsBundlerPlugin = compilation.options.plugins.find(
(plugin) => plugin instanceof FaviconsBundlerPlugin
);
if (faviconsBundlerPlugin && faviconsBundlerPlugin.faviconResponse) {
// Get the outputPathPrefix from FaviconsBundlerPlugin configuration or use default
const outputPathPrefix = faviconsBundlerPlugin.options.faviconOptions?.path || '/defaultDirFaviconManifests';
faviconsBundlerPlugin.faviconResponse.files.forEach(({ name, contents }) => {
const fileExtension = path.extname(name).toLowerCase();
if (this.extensionsToAdjustOutputPath.includes(fileExtension)) {
const outputPath = path.join(outputPathPrefix, name);
compilation.assets[outputPath] = {
source: () => contents,
size: () => contents.length,
};
delete compilation.assets[name];
}
});
}
// Invoke the callback to signal that the plugin has completed its work
callback();
});
}
}
module.exports = AdjustFaviconManifestPathsPlugin;You can use it like this in webpack config file: //import the plugin from you .js file
const AdjustFaviconManifestPathsPlugin = require('./adjust-favicon-manifest-paths-plugin.js')
// throw in the plugin after FaviconsBundlerPlugin()
new AdjustFaviconManifestPathsPlugin({
extensionsToAdjustOutputPath: ['.json', '.webmanifest', '.xml']
}), |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Given below is my webpack config file. FaviconsBundlerPlugin stores all images in provided
faviconOptions.pathbut saves browserconfig.xml , manifest.webmanifest and yandex-browser-manifest.json under default webpack output.path directory.The html output file refers to generated *.xml , *.webmanifest and *.json files as if they were present inside
faviconOptions.pathdirectory - which they are not.How to get to save these files inside provided
faviconOptions.path?Sidenote - if you can share how would I go about troubleshooting such issues on my own that would be great. I looked inside
node_modules/html-bundler-webpack-plugin/plugins/favicons-bundler-plugin/index.jsbut can't pinpoint the code causing this to happen. I have read webpack documentation but could only make sense of some of it. Now I am reading readme for html-bundler-webpack-plugin to better understand webpack. webpack troubleshooting is hard - seems like a black box. If someone can suggest resources or books that beginner can read - that would be great.Beta Was this translation helpful? Give feedback.
All reactions