Gathering detailed insights and metrics for icon-prerender
Gathering detailed insights and metrics for icon-prerender
Gathering detailed insights and metrics for icon-prerender
Gathering detailed insights and metrics for icon-prerender
@iconify-prerendered/vue-lucide
Lucide components for Vue. Designed for ease of use and high performance
@iconify-prerendered/vue-codicon
Codicons components for Vue. Designed for ease of use and high performance
@iconify-prerendered/vue-simple-icons
Simple Icons components for Vue. Designed for ease of use and high performance
@iconify-prerendered/vue-tabler
Tabler Icons components for Vue. Designed for ease of use and high performance
npm install icon-prerender
Typescript
Module System
Min. Node Version
Node Version
NPM Version
38.6
Supply Chain
65.9
Quality
71.3
Maintenance
50
Vulnerability
93.9
License
Cumulative downloads
Total Downloads
Last day
0%
4
Compared to previous day
Last week
-50%
5
Compared to previous week
Last month
266.7%
22
Compared to previous month
Last year
-30.7%
140
Compared to previous year
7
A framework-agnostic plugin (likely compatible with your build tool) that prerenders your SVG icons at build time so your clients don't have to fetch them during browsing. Designed for ease-of-use and maximum performance.
There are several icon libraries out there. However, it is rare to find one that ticks all the following:
This library is heavily inspired by astro-icon
and essentially works the same except:
icon-prerender
works for any framework, even raw HTML (provided you use a bundler)astro-icon
provides icon components - icon-prerender
allows you to use just HTMLicon-prerender
provides much more flexibility on how icons are specifiedicon-prerender
allows you to inline raw SVG elementsAgain, astro-icon
works in this way, but only supports .astro
components and does not work with server-side rendering.
This plugin requires @iconify/json
as a peer dependency:
1npm i --save-dev icon-prerender @iconify/json
1yarn add -D icon-prerender @iconify/json
1pnpm i -D icon-prerender @iconify/json
I also recommend installing and enabling the iconify-intellisense
VSCode extension by Anthony Fu.
In the template, you can define an icon to prerender as either:
data-icon
attribute:
<div>
<span>
<figure>
<img>
<svg>
<svg />
element wrapped around a use
tag with either a href
or xlink:href
attribute i.e.:1<svg> 2 <use href="assets/icon.svg#id"></use> 3</svg>
This last feather sets icon-prerender
from other icon libraries as this is valid HTML - if you disabled icon-prerender
, the above would still work (assuming the href
points to a valid path). The only difference would be it would have to make an extra network request during runtime to fetch the SVG and would then have to render it.
So, the cases above describe the default resolution algorithm; by default, these are the only elements that will be transformed into <svg />
elements. See "Configuration" to see how this can be changed.
Additionally, the data-icon
attribute can either be:
[pack]:[name]
string specifying the icon pack and the specific icon in the pack.svg
file
svg
in the content-type
headerWhatever you provide to data-icon
will be resolved and prerendered at build time.
Any attributes defined on the original element (apart from data-icon
unless it is a [pack]:[name]
string) will be preserved and will override identical attributes in the resolved SVG element, except:
class
will be concatenated from both elements<use>
tag wrapped inside an <svg>
, the <use>
tag will be removedNote that icons can be nested inside each other, however, children will be resolved first. So the innermost icon will be prerendered first.
Then, you use the include the appropriate plugin with in your bundler's config:
1import { defineConfig } from "astro/config"; 2import icons from "icon-prerender/astro"; 3 4export default defineConfig({ 5 integrations: [icons()], 6})
1import { defineConfig } from "vite"; 2import icons from "icon-prerender/vite"; 3 4export default defineConfig({ 5 plugins: [icons()], 6})
1import { defineConfig } from "rollup"; 2import icons from "icon-prerender/rollup"; 3 4export default defineConfig({ 5 plugins: [icons()], 6})
1import esbuild from "esbuild"; 2import icons from "icon-prerender/esbuild"; 3 4esbuild.build({ 5 plugins: [icons()], 6}).catch(() => process.exit(1));
In CommonJS form:
1const IconPrerenderPluginWebpackPlugin = require("icon-prerender/webpack"); 2 3module.exports = { 4 plugins: [new IconPrerenderPluginWebpackPlugin()], 5}
include
- A regex, an array of strings (or regexes) of HTML attributes (can be custom) to
filter elements on
undefined
- enables default filteringexclude
- A regex, an array of strings (or regexes) of HTML attributes (can be custom) to
filter elements on
undefined
- enables default filteringNote: specifying include
or exclude
will not override default filtering - they are used to either include extra elements, or exclude elements that would have been included for transformation by default.
Allow consumers to disable default resolution via a new plugin option
include
and exclude
in tandem with this new plugin optionAdd more component tests, especially with larger files
Have any other ideas? Make a suggestion in the Discussions tab.
To get started with development, you will need an editor (VS Code is recommended), a browser that runs JavaScript and some extra prerequisites:
To get started with contributing to this project, first fork this git repository:
1git clone https://github.com/Ernxst/icon-prerender.git
Then, install dependencies and start coding.
If you have a suggestion that would make this app better, please fork the repo and create a pull request. You can also
simply open an issue with the tag "enhancement
".
git checkout -b feature/AmazingFeature
)git commit -m 'Add some AmazingFeature'
)git push origin feature/AmazingFeature
)Distributed under the MIT License. See LICENSE
for more information.
No vulnerabilities found.
No security vulnerabilities found.