How do I get favicon working with webpack

mine is configured this way

    ...when(!tests, new CopyWebpackPlugin([
      { from: 'static', to: outDir, ignore: ['.*'] }, // ignore dot (hidden) files
      { from: 'favicon.ico', to: 'favicon.ico' },
      { from: 'assets', to: 'assets' }
    ])),

and my favicon.ico is in both static and root, I don’t remember why I have both but anyway it works for me this way so I’m leaving it this way.

EDIT

in another project (not Aurelia though), I got it setup by following the source directory, I think this is better and will work all the time (as opposed to having the favicon in both folders like I wrote earlier).

const srcDir = path.resolve(__dirname, 'src');

new HtmlWebpackPlugin({
      template: 'index.ejs',
      favicon: `${srcDir}/favicon.ico`,
      metadata: {
        // available in index.ejs //
        title, baseUrl
      }
    }),
new CopyWebpackPlugin({
      patterns: [
        { from: 'static', to: outDir, ignore: ['.*'] }, // ignore dot (hidden) files
        { from: `${srcDir}/favicon.ico`, to: 'favicon.ico' },
      ]
    }),
1 Like