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.

How to add favicon to /dist?

See original GitHub issue

Seems trivial but is difficult. How to add a favicon.ico to the npm run build task?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:16
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

315reactions
ryangptscommented, Apr 4, 2017

I only needed this:

In webpack.config.*.js files

new HtmlWebpackPlugin({   
    favicon: 'src/images/favicon.ico'
153reactions
jforakercommented, May 2, 2016

Hmm that is one way. Here’s how I did it in case anyone lands on this thread:

  1. require my favicon in my main App.js entry file require('../assets/images/favicon.ico')

  2. Added a loader configuration that does not scramble the image file names in the build task (per this thread https://github.com/webpack/webpack/issues/1336#issuecomment-171363119)

          {
              test: /\.jpe?g$|\.ico$|\.gif$|\.png$|\.svg$|\.woff$|\.ttf$|\.wav$|\.mp3$/,
              loader: 'file-loader?name=[name].[ext]'  // <-- retain original file name
          }
    
  3. Add the standard <link rel="shortcut icon" href="favicon.ico"> in src/index.html

Now npm run build will output the image/assets names as their original name, hence giving you the ability to href="favicon.ico" right in your index.html

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add Favicon with React and Webpack - Stack Overflow
I am attempting to add a favicon to a React-based website that I made using webpack. It has been a total nightmare to...
Read more >
How do I get favicon working with webpack - Help Requests
I put the same favicon.ico in two different places to try to get this to work and still it is not displayed when...
Read more >
How to Favicon in 2022: Six files that fit most needs
Use copy-webpack-plugin to copy favicon.ico without adding a hash to file name. Bonus tip: create a separate icon for staging. Favicons are a ......
Read more >
favicons-webpack-plugin - npm
Start using favicons-webpack-plugin in your project by running `npm i favicons-webpack-plugin`. ... Install. npm i favicons-webpack-plugin ...
Read more >
Bundle your favicons with Webpack | Tech-Angels publications
The Good Ol' Days of just having a tiny favicon.ico are gone. Generate your favicon files with Real Favicon Generator and bundle them...
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