Skip to content

Cross-platform .NET CLI that generates offline-ready Iconify Cross-platform .NET CLI that generates offline-ready Iconify v3 JavaScript bundles from any set of SVG icons.

License

Notifications You must be signed in to change notification settings

pavadik/IconifyBundler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Iconify Offline Bundle Generator 🎨

A tiny cross-platform CLI tool (C# / .NET 8+) that downloads selected SVG icons from the Iconify API and produces a fully self-contained JavaScript bundle.
Works offline, compatible with Iconify v3, no Node.js required.

build license dotnet

Features

Description
Single call per collection Requests many icons at once → fewer round-trips
📦 Output formats: ESM or IIFE Modern import support or legacy global Iconify
🗂 Includes aliases & chars Keeps original Iconify set structure intact
📝 Simple JSON config List the icons you need, choose the output type—done
🔄 Sample config bootstrap A ready-to-edit icons-config.json is created if missing
🐧 Runs everywhere Windows / macOS / Linux, container-friendly

Quick start

1. Clone & build

git clone https://github.com/your-org/iconify-bundle-generator.git
cd iconify-bundle-generator
dotnet build -c Release

2. Create / edit icons-config.json

{
  // the resulting JS file
  "outputFileName": "iconify-bundle.js",
  // "esm" ‑ modern browsers | "iife" ‑ legacy browsers
  "module": "esm",
  // icons in "prefix:name" format
  "icons": [
    "mdi:home",
    "mdi:account",
    "lucide:mail",
    "heroicons:bell-20-solid"
  ]
}

Tip: run the tool once without a config and the sample file will be generated automatically.

3. Generate the bundle

dotnet run --project IconifyBundleGenerator \
           -- icons-config.json wwwroot/iconify-bundle.js

You will now have wwwroot/iconify-bundle.js ready to ship.


Using the bundle

ESM (recommended)

<!-- HTML / Razor / Blazor -->
<script type="importmap">
{
  "imports": {
    "@iconify/iconify": "https://cdn.jsdelivr.net/npm/@iconify/iconify/dist/iconify.es.mjs"
  }
}
</script>

<script type="module" src="/iconify-bundle.js"></script>

IIFE / UMD (legacy browsers)

<script src="https://cdn.jsdelivr.net/npm/@iconify/iconify@3/dist/iconify.min.js"></script>
<script src="/iconify-bundle.js"></script>

Render an icon

<span class="iconify" data-icon="mdi:home" data-width="24"></span>

ASP.NET Core integration

Add the generated bundle to wwwroot and reference it in your layout/view.

// Program.cs (or Startup.cs)
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorPages();

var app = builder.Build();
app.UseStaticFiles();   // make sure static files are enabled
app.MapRazorPages();
app.Run();
@* _Layout.cshtml *@
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>@ViewData["Title"] - MySite</title>
</head>
<body>
    @RenderBody()

    <!-- ESM variant -->
    <script type="importmap">
    {
      "imports": {
        "@iconify/iconify": "/lib/iconify/iconify.es.mjs" // or CDN url
      }
    }
    </script>
    <script type="module" src="~/iconify-bundle.js"></script>

    <!-- IIFE variant (if you generated `"module": "iife"`) -->
    <!--
    <script src="https://cdn.jsdelivr.net/npm/@iconify/iconify@3/dist/iconify.min.js"></script>
    <script src="~/iconify-bundle.js"></script>
    -->
</body>
</html>

Now you can drop icons anywhere in Razor:

<span class="iconify" data-icon="lucide:mail" data-width="20"></span>

No additional Tag Helpers or components are necessary—Iconify replaces the element at runtime.


Configuration reference

Field Type Default Description
outputFileName string iconify-bundle.js Target JS file name
module "esm" | "iife" esm Bundle type
icons string[] List of icons (prefix:name)

Use "*" to pull an entire collection, e.g. "mdi:*" (can be huge).


FAQ

Question Answer
ReferenceError: addCollection is not defined Generated in IIFE mode but Iconify script is missing. Add the CDN script before the bundle.
Failed to resolve module specifier "@iconify/iconify" Browser needs an Import Map or switch to IIFE mode.
How do I update the bundle when the icon list changes? Edit icons-config.json and run the generator again.
Is it safe for production? Yes—once generated the bundle is an ordinary JS file served by your app/CDN.

Contributing

  1. Fork 💫
  2. Create a feature branch (git checkout -b feat/my-awesome-thing)
  3. Commit (git commit -am 'feat: add my awesome thing')
  4. Push (git push origin feat/my-awesome-thing)
  5. Open a pull request 📬

We welcome PRs and issues of any size—typos included!


License

MIT © 2025 Paul Dikaloff

About

Cross-platform .NET CLI that generates offline-ready Iconify Cross-platform .NET CLI that generates offline-ready Iconify v3 JavaScript bundles from any set of SVG icons.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages