Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removes warning when no icon packs are found #180

Merged
merged 2 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/two-lizards-double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"astro-icon": patch
---

Removes an unecessary warning when only using local icons
9 changes: 6 additions & 3 deletions packages/core/src/vite-plugin-astro-icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export function createPlugin(
if (id === resolvedVirtualModuleId) {
if (!collections) {
collections = await loadIconifyCollections({ root, include });
logCollections(collections, ctx);
}
try {
// Attempt to create local collection
Expand All @@ -43,6 +42,7 @@ export function createPlugin(
} catch (ex) {
// Failed to load the local collection
}
logCollections(collections, { ...ctx, iconDir });
await generateIconTypeDefinitions(Object.values(collections), root);

return `export default ${JSON.stringify(
Expand All @@ -55,13 +55,16 @@ export function createPlugin(

function logCollections(
collections: AstroIconCollectionMap,
{ logger }: PluginContext,
{ logger, iconDir }: PluginContext & { iconDir: string },
) {
if (Object.keys(collections).length === 0) {
logger.warn("No icons detected!");
return;
}
const names: string[] = Object.keys(collections);
const names: string[] = Object.keys(collections).filter((v) => v !== "local");
if (collections["local"]) {
names.unshift(iconDir);
}
logger.info(`Loaded icons from ${names.join(", ")}`);
}

Expand Down