function getFaviconsOpts() {
  const config = require("../config");
  const { getProjectTitle, getOptions } = require("../utils");

  return getOptions("config.favicons", {
    appName: getProjectTitle(), // Your application's name. `string`
    appDescription: "", // config.pkg.description, // Your application's description. `string`
    version: config.pkg.version, // Your application's version string. `string`
    url: process.env.APP_URL,
    appShortName: null, // Your application's short_name. `string`. Optional. If not set, appName will be used
    developerName: null, // Your (or your developer's) name. `string`
    developerURL: null, // Your (or your developer's) URL. `string`
    display: "standalone", // Preferred display mode: "fullscreen", "standalone", "minimal-ui" or "browser". `string`
    background: "#fff", // Background colour for flattened icons. `string`
    theme_color: "#fff", // Theme color user for example in Android's task switcher. `string`
    // appleStatusBarStyle: "black-translucent", // Style for Apple status bar: "black-translucent", "default", "black". `string`
    dir: "auto", // Primary text direction for name, short_name, and description
    lang: "it", // Primary language for name and short_name
    orientation: "any", // Default orientation: "any", "natural", "portrait" or "landscape". `string`
    scope: "/", // set of URLs that the browser considers within your app
    start_url: "/?homescreen=1", // Start URL when launching the application from a device. `string`
    pixel_art: false, // Keeps pixels "sharp" when scaling up, for pixel art.  Only supported in offline mode.
    loadManifestWithCredentials: false, // Browsers don't send cookies when fetching a manifest, enable this to fix that. `boolean`
  });
}

module.exports = () => {
  const HtmlWebpackPlugin = require("html-webpack-plugin");
  const FaviconsWebpackPlugin = require("favicons-webpack-plugin");
  const config = require("../config");
  const paths = require("../paths");
  // const partialPreFilename = config.filenames.faviconsPartial + "l";
  const partialFilename = config.filenames.faviconsPartial;

  return [
    new HtmlWebpackPlugin({
      filename: partialFilename,
    }),
    new FaviconsWebpackPlugin({
      inject: (htmlPlugin) => {
        return basename(htmlPlugin.options.filename) === partialFilename;
      },
      logo: paths.join(paths.frontend.src.favicons, "favicon.png"),
      mode: "webapp",
      devMode: "webapp",
      favicons: getFaviconsOpts(),
      prefix: paths.frontend.dest.folders.favicons + "/",
      // path: getPublicUrls().favicons,
    }),
  ];
};
