Skip to content

Commit 580b5cd

Browse files
Removes warning when no icon packs are found (#180)
* fix(#176): removes warning when no icon packs are found * chore(lint): Prettier fix --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 38a3a90 commit 580b5cd

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

.changeset/two-lizards-double.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"astro-icon": patch
3+
---
4+
5+
Removes an unecessary warning when only using local icons

packages/core/src/vite-plugin-astro-icon.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ export function createPlugin(
3434
if (id === resolvedVirtualModuleId) {
3535
if (!collections) {
3636
collections = await loadIconifyCollections({ root, include });
37-
logCollections(collections, ctx);
3837
}
3938
try {
4039
// Attempt to create local collection
@@ -43,6 +42,7 @@ export function createPlugin(
4342
} catch (ex) {
4443
// Failed to load the local collection
4544
}
45+
logCollections(collections, { ...ctx, iconDir });
4646
await generateIconTypeDefinitions(Object.values(collections), root);
4747

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

5656
function logCollections(
5757
collections: AstroIconCollectionMap,
58-
{ logger }: PluginContext,
58+
{ logger, iconDir }: PluginContext & { iconDir: string },
5959
) {
6060
if (Object.keys(collections).length === 0) {
6161
logger.warn("No icons detected!");
6262
return;
6363
}
64-
const names: string[] = Object.keys(collections);
64+
const names: string[] = Object.keys(collections).filter((v) => v !== "local");
65+
if (collections["local"]) {
66+
names.unshift(iconDir);
67+
}
6568
logger.info(`Loaded icons from ${names.join(", ")}`);
6669
}
6770

0 commit comments

Comments
 (0)