jantimon / favicons-webpack-plugin

Let webpack generate all your favicons and icons for you
MIT License
1.2k stars 210 forks source link

[Feature Request] Allow custom filename (manifest.json -> custom.webmanifest) #272

Closed latipun7 closed 2 years ago

latipun7 commented 3 years ago

Is your feature request related to a problem? Please describe. Current outputted filename manifest.json is not a standard file extension for webmanifest. Correct manifest extension is .webmanifest

Describe the solution you'd like Allow custom filename in the configuration.

plugins: [
  new FaviconsWebpackPlugin({
    // Custom manifest filename (default: manifest.json)
    filename: 'mysite.webmanifest',
  })
]

Describe alternatives you've considered Rename manifest.json in index file to site.webmanifest.

Additional context issue

devlegacy commented 3 years ago

An alternative could be to create hook

compiler.hooks.thisCompilation.tap('FaviconsWebpackPlugin', compilation => {

      compilation.hooks.processAssets.tapPromise(
        {
          name: 'FaviconsWebpackPlugin',
          stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONS
        },
        async () => {
          const faviconCompilation = faviconCompilations.get(compilation);
          if (!faviconCompilation) {
            return;
          }
          const faviconAssets = (await faviconCompilation).assets;

         // here we can alter the output - start hook (?)
          for(const asset of faviconAssets) {
            if(asset.name === 'manifest.json') {
              asset.name = 'manifest.webmanifest'
              faviconAssets.push(asset)
              break
            }
          }
         // here we can alter the output - end hook (?)

          faviconAssets.forEach(({ name, contents }) => {
            compilation.emitAsset(name, contents);
          });
        }
      );
    });
bencresty commented 2 years ago

+1

In projects webpack here uses a rename plugin to rename the file after build, but it would be better if we could just directly set the right name.

Isn't manifest.webmanifest a better default name too or is there still something around that uses manifest.json?

stale[bot] commented 2 years ago

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.

latipun7 commented 2 years ago

Still relevant ig