Tools Favicon
Multi-platform favicon generator CLI — Android, Apple, Windows, Yandex, and standard favicons from a single source image.
@vitus-labs/tools-favicon generates favicons and web app manifests from a single source image, powered by favicons v7. It produces favicon.ico, Apple touch icons and startup images, Android homescreen icons, Windows tiles, Yandex icons, and a PWA manifest.
Installation
npm install @vitus-labs/tools-faviconRequirements
- Node.js
>= 22(ESM-only)
Quick Start
Configure in vl-tools.config.mjs:
export default {
favicon: {
icons: [
{
input: 'src/assets/logo.png',
output: 'public/favicons',
path: '/favicons',
},
],
},
}Run:
vl_faviconOr add a script:
{
"scripts": {
"favicon": "vl_favicon"
}
}Configuration
Configure via vl-tools.config.mjs under the favicon key. Your values are deep-merged over the defaults below:
export default {
favicon: {
// Base public URL path of the generated files
path: '/',
// Icon source/output entries (array)
icons: [
{
input: 'src/assets/logo.png', // Source image (relative to cwd, or absolute)
output: 'public/favicons', // Output directory (relative to cwd, or absolute)
path: '/favicons', // URL path, appended to the base `path`
},
],
// PWA manifest settings
dir: 'auto',
lang: 'en-US',
background: '#fff',
theme_color: '#fff',
appleStatusBarStyle: 'black-translucent',
display: 'standalone',
orientation: 'any',
scope: '/',
start_url: '/?homescreen=1',
version: '1.0',
// Feature flags
logging: false,
pixel_art: false,
loadManifestWithCredentials: false,
// Per-platform toggles (passed to `favicons` as its `icons` option)
platforms: {
android: true,
appleIcon: true,
appleStartup: true,
favicons: true,
windows: true,
yandex: true,
},
},
}Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
icons | Array<{ input, output, path? }> | [] | Icon sources. Each entry is generated independently; output directories are created if missing |
path | string | '/' | Base public URL path used in manifests and HTML. Joined with each entry's path using exactly one / |
platforms | Record<string, boolean | object | array> | all true | Per-platform toggles, e.g. { appleStartup: false } |
dir | string | 'auto' | Text direction for PWA manifest |
lang | string | 'en-US' | Language tag (BCP 47) |
background | string | '#fff' | Background color for flattened icons and manifest |
theme_color | string | '#fff' | Theme color for browser UI |
appleStatusBarStyle | string | 'black-translucent' | Apple status bar style |
display | string | 'standalone' | PWA display mode |
orientation | string | 'any' | Default screen orientation |
scope | string | '/' | PWA scope |
start_url | string | '/?homescreen=1' | PWA start URL |
version | string | '1.0' | App version in manifest |
logging | boolean | false | Enable favicons console logging |
pixel_art | boolean | false | Keep pixels sharp when scaling |
loadManifestWithCredentials | boolean | false | Include credentials when fetching manifest |
Any other option accepted by favicons (e.g. appName, appShortName, appDescription) is passed through as-is.
icons used to hold the platform toggles object. That shape is still accepted, but logs a deprecation warning — move the toggles to platforms and use icons for the array of sources.
Platform Toggles
Each key in platforms can be true (generate), false (skip), an options object, or an array of sources:
| Platform | Default | Generated Icons |
|---|---|---|
android | true | android-chrome-*.png homescreen icons (36–512 px, plus maskable variants) |
appleIcon | true | apple-touch-icon*.png (57–1024 px) |
appleStartup | true | apple-touch-startup-image-*.png iOS splash screens |
favicons | true | favicon.ico, favicon-16x16.png, favicon-32x32.png, favicon-48x48.png |
windows | true | mstile-*.png tiles + browserconfig.xml |
yandex | true | yandex-browser-50x50.png + yandex-browser-manifest.json |
The default config also sets coast: true and firefox: true, but favicons v7 no longer supports these platforms — they produce no output.
Platform Options
{
platforms: {
android: {
offset: 10, // Offset percentage
background: '#0066cc', // Custom background
mask: true, // Circular mask
overlayGlow: false, // Glow effect
overlayShadow: false, // Drop shadow
},
windows: false, // Disable Windows tiles
appleStartup: false, // Disable iOS splash screens
},
}Generated Files
All files for an entry are written into its output directory:
- Images — see the platform table above
manifest.webmanifest— Web App Manifest (Android)browserconfig.xml— Windows tile configurationyandex-browser-manifest.json— Yandex metadata
Programmatic API
import { generateFavicons, configuration } from '@vitus-labs/tools-favicon'
// Generate favicons
await generateFavicons()
// Access default configuration
console.log(configuration)generateFavicons()
generateFavicons(): Promise<void>Loads configuration from vl-tools.config.mjs, generates favicons for each icons entry, and writes files to disk.
- Logs a warning and returns early when no
iconsare configured - Validates each entry —
inputandoutputare required - Processes all entries in parallel (
Promise.allSettled), so one failing entry doesn't stop the others - After all entries finish, logs each failure and throws
N favicon generation(s) failed(the CLI exits non-zero)
configuration
The default configuration object (before merging with user config):
const configuration: ConfigurationMultiple Icon Sets
Generate different favicon sets for different contexts:
export default {
favicon: {
icons: [
{
input: 'src/assets/main-logo.png',
output: 'public/favicons',
path: '/favicons',
},
{
input: 'src/assets/admin-logo.png',
output: 'public/admin/favicons',
path: '/admin/favicons',
},
],
},
}Each entry generates a complete set of favicons independently.
Exports
import {
generateFavicons,
configuration,
} from '@vitus-labs/tools-favicon'
import type { Configuration } from '@vitus-labs/tools-favicon'Last updated on