npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@impactdk/svg

v1.0.2

Published

Optimize and transform SVGs to inline consts in JavaScript/TypeScript file

Downloads

48

Readme

svg

This package is a compilation of different tools to transform SVGs including a binary to convert a folder into inline SVGs in TypeScript.

Usage

Example folder structure:

  • icons/facebook.svg
  • icons/this-is-a-subfolder/youtube.svg

Transform all svgs inside the icons folder with this command:

transform-svg ./icons ./generated.ts

Configuration

Optional watch flag to watch folder continuously for changes:

transform-svg ./icons ./generated.ts --watch

Optional path to SVGO config

transform-svg ./icons ./generated.ts --svgo='./svgo-config.json'

Config json file follows SVGO config standard:

[
    { "removeXMLNS": true },
    { "removeViewBox": false },
    { "removeDimensions": true }
]

Output

Example contents of the outputted file generated.ts:

export const facebook =
    '<svg #facebook class="svg-facebook svg-icon" viewBox="0 0 50 50"><circle fill="#FED00F" cx="25" cy="25" r="25"/><path fill="#33363B" d="M29 15h3.5c.3 0 .5-.2.5-.5v-4c0-.3-.2-.5-.5-.5h-4c-3.7 0-6.5 2.8-6.5 6.5V21h-4.5c-.3 0-.5.2-.5.5v4c0 .3.2.5.5.5H22v13.5c0 .3.2.5.5.5h4c.3 0 .5-.2.5-.5V26h4.5c.2 0 .4-.2.5-.4l1-4c0-.1 0-.3-.1-.4-.1-.1-.2-.2-.4-.2H27v-4c0-1.1.9-2 2-2z"/></svg>';
export const thisIsASubfolderYoutube =
    '<svg #thisIsASubfolderYoutube class="svg-this-is-a-subfolder-youtube svg-icon" viewBox="0 0 32 32"><path fill="#444" d="M31.7 9.6s-.3-2.2-1.3-3.2c-1.2-1.3-2.6-1.3-3.2-1.4-4.5-.3-11.2-.3-11.2-.3s-6.7 0-11.2.3c-.6.1-2 .1-3.2 1.4C.6 7.4.3 9.6.3 9.6S0 12.2 0 14.8v2.4c0 2.6.3 5.2.3 5.2s.3 2.2 1.3 3.2c1.2 1.3 2.8 1.2 3.5 1.4 2.6.2 10.9.3 10.9.3s6.7 0 11.2-.3c.6-.1 2-.1 3.2-1.4 1-1 1.3-3.2 1.3-3.2s.3-2.6.3-5.2v-2.4c0-2.6-.3-5.2-.3-5.2zm-19 10.6v-9l8.6 4.5-8.6 4.5z"/></svg>';