npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@johnfmorton/favicon-generator-craftcms

v0.1.2

Published

Generate favicon assets, manifests, and HTML tags for Craft CMS + Vite projects

Readme

craft-favicon-generator

Generate a complete set of favicon and web app assets from a single source PNG image. Built for Craft CMS + Vite projects, but works anywhere.

Uses the favicons package (v7+, built on sharp) to produce icons for every major platform, manifest files, and a ready-to-include HTML snippet.

Installation

npm install @johnfmorton/favicon-generator-craftcms

Quick Start

1. Create a Config File

Add craft-favicon-generator.config.mjs to your project root:

export default {
  appName: 'Your Site Name',
}

That's it for the minimum config. All other options have sensible defaults for Craft CMS projects.

2. Add a Source Image

Place a high-resolution PNG (at least 512x512, ideally 1024x1024) at src/img/favicon-src.png, or set a custom source path in your config.

3. Run the Generator

npx craft-favicon-generator

Configuration

Only appName is required. Everything else has defaults tuned for Craft CMS + Vite projects.

Full Example

export default {
  // Required
  appName: 'My Site',

  // Paths (relative to project root)
  source: 'src/img/favicon-src.png',       // default
  outputDir: 'web/dist/assets/favicons',    // default
  pathPrefix: '/dist/assets/favicons',      // default

  // App metadata
  appDescription: 'A short description of your site.',
  appShortName: 'MySite',                   // defaults to appName
  developerName: 'Your Name',
  developerURL: 'https://your-site.com',

  // Appearance
  background: '#fff',
  theme_color: '#fff',

  // Platform toggles (all true by default)
  icons: {
    android: true,
    appleIcon: true,
    appleStartup: true,
    favicons: true,
    windows: true,
    yandex: false,
  },
}

Default Values

| Option | Default | Description | |---|---|---| | source | src/img/favicon-src.png | Path to source PNG image | | outputDir | web/dist/assets/favicons | Where generated files are written | | pathPrefix | /dist/assets/favicons | URL path prefix in generated HTML/manifests | | appDescription | '' | App description for manifests | | appShortName | value of appName | Short name for home screen | | background | #fff | Background color for splash screens | | theme_color | #fff | Browser toolbar color on mobile | | lang | en-US | Language | | display | minimal-ui | PWA display mode | | icons.android | true | Generate Android icons | | icons.appleIcon | true | Generate Apple Touch icons | | icons.appleStartup | true | Generate Apple startup images | | icons.favicons | true | Generate standard favicons | | icons.windows | true | Generate Windows tile images | | icons.yandex | true | Generate Yandex browser assets |

See the favicons documentation for additional options.

Craft CMS Integration

The generator produces a webapp.html file containing all <link> and <meta> tags. Use the Craft Vite plugin's inline() method to embed it in your template's <head>:

<head>
  {# Favicons, webapp manifests, etc. #}
  {{ craft.vite.inline("@webroot/dist/assets/favicons/webapp.html") }}
</head>

Without the Craft Vite plugin:

{{ source('@webroot/dist/assets/favicons/webapp.html', ignore_missing = true) }}

Programmatic API

import { generate } from '@johnfmorton/favicon-generator-craftcms'

const result = await generate({
  source: '/absolute/path/to/favicon-src.png',
  outputDir: '/absolute/path/to/output',
  pathPrefix: '/dist/assets/favicons',
  faviconOptions: {
    appName: 'My App',
    background: '#fff',
    theme_color: '#fff',
    icons: { android: true, appleIcon: true, favicons: true },
  },
})

console.log(result)
// { images: 25, files: 3, html: 1, failed: 0 }

When using the programmatic API, all paths must be absolute. The faviconOptions object is passed directly to the favicons package.

Environment Variables

The CLI will load a .env file if dotenv is installed in your project. This is optional and not a hard dependency.

When to Run

Favicons only need to be regenerated when:

  • You change the source image
  • You update app metadata (name, colors, etc.)
  • You update the favicons npm package

There is no need to run this on every build.

License

MIT