All Projects → antfu → Purge Icons

antfu / Purge Icons

Licence: mit
🎐 Bundles icons on demand

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Purge Icons

Smart Hierarchy
Better hierarchy for Unity.
Stars: ✭ 234 (+157.14%)
Mutual labels:  tools, icons
Kubernetes Icons
[obsolete] Set of icons for Kubernetes diagrams, has been merged into official k8s repo!!
Stars: ✭ 194 (+113.19%)
Mutual labels:  tools, icons
Suru Plus Ubuntu
Suru++ Ubuntu — An elegant third-party icons theme based on Sam Hewitt's Suru Icons
Stars: ✭ 85 (-6.59%)
Mutual labels:  icons
Httptoolkit Ui
The UI of HTTP Toolkit
Stars: ✭ 91 (+0%)
Mutual labels:  tools
Osmic
CC0 SVG Map Icons, mirror of repo on Gitlab
Stars: ✭ 89 (-2.2%)
Mutual labels:  icons
Git pentesting toolkit
Exploit pack for pentesters and ethical hackers.
Stars: ✭ 86 (-5.49%)
Mutual labels:  tools
A File Icon Idea
Atom File Icons plugin for IntelliJ IDEA products
Stars: ✭ 90 (-1.1%)
Mutual labels:  icons
Vxscan
python3写的综合扫描工具,主要用来存活验证,敏感文件探测(目录扫描/js泄露接口/html注释泄露),WAF/CDN识别,端口扫描,指纹/服务识别,操作系统识别,POC扫描,SQL注入,绕过CDN,查询旁站等功能,主要用来甲方自测或乙方授权测试,请勿用来搞破坏。
Stars: ✭ 1,244 (+1267.03%)
Mutual labels:  tools
Alfred Calculate Anything
Alfred Workflow to calculate anything with natural language
Stars: ✭ 92 (+1.1%)
Mutual labels:  tools
Vscode Great Icons
🆚 A big pack of icons (100+) for your files
Stars: ✭ 88 (-3.3%)
Mutual labels:  icons
Gohacktools
Hacker tools on Go (Golang)
Stars: ✭ 1,303 (+1331.87%)
Mutual labels:  tools
Jcabi
Elementary Java Components
Stars: ✭ 87 (-4.4%)
Mutual labels:  tools
Runtimes Common
Common tools used by the GCP runtimes.
Stars: ✭ 86 (-5.49%)
Mutual labels:  tools
Material Design Icons
Material Design Icons
Stars: ✭ 90 (-1.1%)
Mutual labels:  icons
Sense Navigation
Sheet Navigation + Actions for Qlik Sense.
Stars: ✭ 85 (-6.59%)
Mutual labels:  icons
Css Flags
A collection of pure CSS flags, all single divs.
Stars: ✭ 90 (-1.1%)
Mutual labels:  icons
Materialdesign
✒6200+ Material Design Icons from the Community
Stars: ✭ 9,669 (+10525.27%)
Mutual labels:  icons
Xclwinkits
一个实用的windows小工具集合,里面包含了多个常用的小软件。其中的批量修改文件名及文件内容功能,可以自定义修改规则,支持规则的导入与导出。不需要安装Office软件,支持Excel/Word/Txt等文件的文件名或文件内容的批量修改操作。另外还包括正则表达式测试小工具、字符串转js常量工具、加密与解密和日期时间差等,您也可以很方便地扩展相关功能。
Stars: ✭ 87 (-4.4%)
Mutual labels:  tools
Adwaita Plus
GNOME++, a third-party icons theme, based on new GNOME 3.32's Adwaita
Stars: ✭ 89 (-2.2%)
Mutual labels:  icons
Cores Swervolf
FuseSoC-based SoC for SweRV EH1
Stars: ✭ 92 (+1.1%)
Mutual labels:  tools

PurgeIcons

Bundles only the icons you use

Think about TailwindCSS + PurgeCSS, but for Icons.

GIF Demo

Intro

PurgeIcons is heavily inspired from PurgeCSS. It analyzes your source code or dist files, extracting the icon names you used, and then bundle the icons' data (SVGs) into your code.

You will only get icons you need. No extra bandwidth, no unused icons, no compromise.

Underneath, it's powered by Iconify, which you get access to 80+ popular open source iconsets with over 5,000 icons to choice, including Material Design Icons, Font Awesome, Octicon and even Emojis!

Browser the icon sets in Icônes or Iconify.

Usage

Just like what you used to do for Iconify.

<span class="iconify" data-icon="fa:home"></span>

Or even dynamic

const span = createElement('span')
span.class = 'iconify'
span.data.icon = isDark ? 'carbon:moon' : 'carbon:sun'

// DON'T, PurgeIcons won't extract them correct.
// add them to `included` to be always bundled if you really want this
span.data.icon = `carbon:${isDark ? 'moon' : 'sun'}`

Install

PurgeIcons is designed to be framework independent, but using framework plugins is the most recommended way to get started. Check out the supported frameworks in the following list. We are trying to make more frameworks able to use PurgeIcons out-of-box. Pull requests are great welcome!

Official Plugins

Plugin Example Template
Vite vite-plugin-purge-icons Example Vitesse
Nuxt nuxt-plugin-purge-module Example
Vue CLI Coming...
Gridsome Coming...
Parcel Coming...
Webpack purge-icons-webpack-plugin
Rollup rollup-plugin-purge-icons

Command Line Interface

The CLI is still working in progress and the design is not yet finalized.

You can either install PurgeIcons as a dev dependency and use the CLI with npx or you can also install PurgeIcons globally:

npm i -g purge-icons

Scan the all the html file and geneted a mjs bundle

purge-icons --content 'src/*.html' --format mjs --output output.js

From multiple sources and use args shorthands, format can be auto inferred from the output option

purge-icons -c 'index.html,src/**/*.vue' -o output.ts

Or export plain json file for other tools to process

purge-icons -c index.html -o output.json

See more options by

purge-icons --help

Programmatic API

Programmatic API is still working in progress as well.

For programmatic use only, you can use @purge-icons/core

npm i -D @purge-icons/core
import { PurgeIconsOptions, PurgeIcons } from '@purge-icons/core'

const code = await PurgeIcons({
  // globs for searching source file to analyze
  content: [
    '**/*.html',
    '**/*.js',
    '**/*.vue', // scan for .vue file as well
  ],
  // whitelist for icons that might be used dynamically
  included: [
    'mdi:account-circle-outline', // from Material Design Icons
    'fa:camera', // from Font Awesome 4
  ],
  format: 'mjs'
})

// code is generated with inlined icons's data, bundle the file and it's done.
fs.promises.writeFiles('./icons.mjs', code, 'utf-8')

Options

export interface PurgeIconsOptions {
  content?: (string | RawContent)[]
  included?: string[]
  extractors?: Extractor[]
  iconSource?: IconSource // default to 'auto'
}

How It Works

Iconify is an icon framework that provide an unified syntax to use icons from its huge collections on-demanded. Each icon set has a id as the prefix of for its icons. For example:

<span class="iconify" data-icon="fa:home"></span>   <!-- Font Awesome -->
<span class="iconify" data-icon="noto:bird"></span> <!-- Note Icons -->
<span class="iconify" data-icon="mdi:alert"></span> <!-- Material Design Icons -->

Iconify achieve that by building up a API service that only send the icons you need. It provides a great flexibility that you can try with different design style and without to worry about including a large amount of unused icons that eat up your bandwidth and slow down your page load.

However, the downside of API querying is that the icons won't be available on the first meaningful paint and your app will be heavy relied on the API servers' status and so its accessability for your users. Iconify also provides the offline solution by implementing frameworks components. In that way, you would need to manually import every icon you use.

Thus, PurgeIcons was born. By scanning your code, it generates bundles for Iconify and load them synchronously. You can use icons in the exact same way as you would with the API based solution.

TODO

  • CLI output
  • Better caching
  • Plugins for frameworks (Vue CLI, Nuxt.js, Next.js, etc.) PR welcome!
  • Font-based icons (Javascript Free)

License

MIT License © 2020 Anthony Fu

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].