| | Related | ||
| | Compress 🗜️ | ||
This Astro integration brings favicon generation utilities
to your Astro project.
Automatically generates comprehensive favicon sets during build, including:
Note
Favicongenerates static favicon files during the Astro build phase.
There are two ways to add integrations to your project. Let's try the most convenient option first!
astro add commandAstro includes a CLI tool for adding first party integrations: astro add. This
command will:
astro.config.* file to apply this integrationTo install Favicon, run the following from your project directory and follow
the prompts:
Using NPM:
npx astro add @playform/favicon
Using Yarn:
yarn astro add @playform/favicon
Using PNPM:
pnpx astro add @playform/favicon
First, install the Favicon integration like so:
npm install -D -E @playform/favicon
Then, apply this integration to your astro.config.* file using the
integrations property:
astro.config.ts
export default {
integrations: [(await import("@playform/favicon")).default()],
};
The integration will now automatically generate favicon files during the build process using the default settings.
Default settings include:
You can override any of the default options. You can see the full option
interface here:
Source/Interface/Integration.ts
sourceThe path to the source icon file (SVG).
string"Source/Asset/PlayForm.svg"darkSourceThe path to the dark mode source icon file (SVG).
string | undefined"Source/Asset/Dark/PlayForm.svg"pathThe output path for favicon files (relative to the public directory).
string"/"settingsFavicon generation settings. Pass false to disable favicon generation, or
an object with specific settings.
IconSettings | boolean{} (uses built-in defaults)settings.desktopDesktop favicon settings including light and dark mode icons.
DesktopSettings | boolean{
regularIconTransformation: {
type: "background",
backgroundColor: "#eaeaea",
backgroundRadius: 0.4,
imageScale: 0.7,
},
darkIconType: "specific",
darkIconTransformation: {
type: "background",
backgroundColor: "#151515",
backgroundRadius: 0.4,
imageScale: 0.7,
},
}
settings.touchiOS touch icon settings.
TouchSettings | boolean{
transformation: {
type: "background",
backgroundColor: "#eaeaea",
backgroundRadius: 0,
imageScale: 0.7,
},
appTitle: "PlayForm",
}
settings.webAppManifestWeb app manifest settings.
WebAppManifestSettings | boolean{
transformation: {
type: "background",
backgroundColor: "#eaeaea",
backgroundRadius: 0,
imageScale: 0.8,
},
backgroundColor: "#eaeaea",
themeColor: "#eaeaea",
name: "PlayForm",
shortName: "PlayForm",
}
injectWhether to inject favicon HTML into the build output logs.
booleantrueloggerCustom logger function for build output messages.
(message: string) => voidconsole.logastro.config.ts
export default {
integrations: [
(await import("@playform/favicon")).default({
source: "Source/Asset/CustomIcon.svg",
darkSource: "Source/Asset/CustomDarkIcon.svg",
}),
],
};
astro.config.ts
export default {
integrations: [
(await import("@playform/favicon")).default({
path: "/assets/favicons/",
}),
],
};
astro.config.ts
export default {
integrations: [
(await import("@playform/favicon")).default({
settings: {
desktop: {
regularIconTransformation: {
type: "background",
backgroundColor: "#ffffff",
backgroundRadius: 0.5,
imageScale: 0.8,
},
},
touch: {
appTitle: "My App",
},
webAppManifest: {
name: "My Application",
shortName: "MyApp",
backgroundColor: "#ffffff",
themeColor: "#ffffff",
},
},
}),
],
};
See CHANGELOG.md for a history of changes to this integration.