favicon generation using realfavicongenerator.net
- Upon installation it creates a new entry in your
package.json
'sscripts
section:
{
"scripts": {
"generate-favicon": "node node_modules/@marfalkov/laravel-real-favicon/index.js"
},
}
-
Once your single source image file is ready it will generate your favicons from it.
-
It generates a partial in
resources/views/partials/favicon.blade.php
-
It inserts an include after your meta tags into
resources/views/app.blade.php
:
@include('partials.favicon')
When do you need to generate favicons for a site? Probably when you are in the early stage of development and have the original favicon source file ready. Then later when you want to change the favicon. A laravel mix task is not an ideal solution for this purpose, so I decided to take a different approach. This task is a perfect match for an npm script that you can use only when you need it, instead of polluting your webpack.mix.js
.
npm install --save-dev @marfalkov/laravel-real-favicon
-
Put your single favicon source image file with .jpg, .png or .svg extension to
/resources/favicon/original/
-
Make sure you have an
app.blade.php
inresources/views
If you wish to have your main layout elsewhere or name it other thanapp.blade.php
you can change it inresources/favicon/config/options.json
npm run generate-favicon
-
Enjoy your generated favicons!
-
When you need to change your favicon just replace the original in
resources/favicon/original
andnpm run generate-favicon
Webapix (Send those guys a postcard, they love postcards!)
- clean up code
- write tests
- add git hooks
- add release-it
npm install --ignore-scripts
License: MIT