Gathering detailed insights and metrics for rollup-plugin-iconify-svg
Gathering detailed insights and metrics for rollup-plugin-iconify-svg
Gathering detailed insights and metrics for rollup-plugin-iconify-svg
Gathering detailed insights and metrics for rollup-plugin-iconify-svg
npm install rollup-plugin-iconify-svg
Typescript
Module System
Node Version
NPM Version
JavaScript (80.08%)
Svelte (11.42%)
CSS (6.26%)
HTML (2.24%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
77 Commits
1 Watchers
5 Branches
1 Contributors
Updated on Jun 06, 2021
Latest Version
2.2.4
Package Id
rollup-plugin-iconify-svg@2.2.4
Unpacked Size
367.09 kB
Size
104.28 kB
File Count
43
NPM Version
7.10.0
Node Version
16.0.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
An experimental rollup plugin to run svelte-iconify-svg
If you're trying out different icons, or icon collections in your project - it takes time to find and include the right files in your template whether they are fonts or SVGs or images. Yes it's great to be able to search for icons from multiple icon sets in https://iconify.design but even then you usually need to export each icon - or use their (very nice) Iconify API to dynamically include them.
But what if you're app works offline, or is embedded, or you just don't want to call another CDN script for every page load, when you just want to try out a couple of icons.
This plugin allows you to simply type an icon reference into your svelte app code, hit save, and reload the page to view the auto-bundled icon svg markup!
Checks the contents of all your files in the supplied 'src' directories for any references to 'iconify' icons.
i.e. any text in the format 'alphanumericordashes colon alphanumericordashes' such as fa:random
or si-glyph:pin-location-2
It then uses the Iconify API to generate markup for each icon reference found, then the plugin simply saves a .js file which exports an icons
object of them all, which gets auto-bundled into your app.
npm i rollup-plugin-iconify-svg --save-dev
// ...other rollup imports
import rolluppluginiconifysvg from "rollup-plugin-iconify-svg";
export default {
// ...other rollup config
plugins: [
rolluppluginiconifysvg({
targets: [{ src: "src", dest: "src/icons.js" }],
}),
// ...other rollup plugins
// If you are using livereload, you may need to add a 'delay' to allow some time for the icons file to be created
!production && livereload({ watch: "public", delay: 1000 }),
// If you are using watch, you may need to exclude the dest file(s) to avoid recursive watching!
watch: {
clearScreen: false,
exclude:["src/icons.js"]
},
]
};
The simplest project would be similar to example 1 in Working Examples below
// ./src/App.svelte
<script>
import icons from "./src/icons.js"; // this is the 'dest' file which the plugin has generated
</script>
{@html icons["fa:random"]}
So in this simple example, assuming you have set 'src' as the 'src' directory and 'src/icons.js' as the 'dest' in the rollup plugin options - then
{@html icons["line-md:emoji-grin"]}
to the App.svelte file above, hit save, your dev build will auto-refresh showing the new icon!Clone this repo
Basic test: Run npm run test_dev
and visit localhost:5000
to build and view the first example and auto-generate the icon file /example/src/icons.js
(like the example described above)
https://github.com/Swiftaff/rollup-plugin-iconify-svg/tree/master/example
More features: Run npm run test2_dev
and visit localhost:5001
to build the second example and auto-generate 2 icon files /example2/src/subfolder/icons1.js
& /example2/src/icons2.js
. This is because of the array of 2 x targets in rollup.config.js - for when you wish to generate multiple icon files for different parts of your app.
https://github.com/Swiftaff/rollup-plugin-iconify-svg/tree/master/example2
This example also shows some basic ways to colour and size your icons using CSS
And if you see 'undefined' appearing in your UI, like in this example - you may have an icon name typo. Just check the generated icons.js file - at the top and it should list any errors, as you can see in /example2/src/subfolder/icons1.js
.
/*
x ERROR no such icon prefix 'emojione-wrong:' - in these icon names ('emojione-wrong:speak-no-evil-monkey')
x ERROR no such icon name 'emojione:hear-no-evil-monkey-wrong'
*/
The latest version is recommended, but if you do wish to use earlier versions please note the import syntax changed from 2.0.0 onwards to the above import syntax. Earlier versions use this syntax instead...
import { icons } from "./src/icons.js";
And if you have issues with a clean first build of your app, where it expects the icons.js file(s) to already exists and won't build because they are missing e.g. via github Actions or other automated build process, you can try this workaround to simply add a placeholder for the expected built icon file(s),
e.g. in example 1 you would add example/src/icons.js
and for example 2, you would add these files example2/src/subfolder/icons.js
and example2/src/icons1.js
These placeholders can be a copy of a previously built version of the final files, or maybe just an empty export to then allow the build process to proceed and re-generate them...
export default = {};
This should be working in v2 upwards, but please report any issues.
This plugin obviously inlines each instance of the SVG on the page - so probably not recommended if you are using hundreds of icons! But you can split them into multiple files if that helps.
Using inline mono SVGs (rather than via separate svg files in object or img tags or via css background-image) does mean they can inherit the colour from CSS for easy icon colouring :-) See example2 above
This project is licensed under the MIT License.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
25 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More