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

rollup-plugin-stdf-icon

v0.0.15

Published

A Rollup plugin that combines a series of svg into one symbol for use in the STDF project

Downloads

30

Readme

简体中文

Introduction

This is a Rollup plugin that combines all SVG files in specified folders (supports multiple) into a single SVG symbol for use in STDF projects. It is compatible with Vite and can be used in Vue or React projects created with Vite.

For more information about the STDF Icon component, please refer to the Icon Guide.

Installation

Using PNPM:

pnpm i rollup-plugin-stdf-icon -D

Using NPM:

npm i rollup-plugin-stdf-icon -D

With BUN:

bun i rollup-plugin-stdf-icon -D

Usage

Configure the plugin in vite.config.js or vite.config.ts:

// ...
import svgSprite from 'rollup-plugin-stdf-icon';

export default defineConfig({
	// ...
	plugins: [
		// ...
		svgSprite(),
		// ...
	],
	// ...
});

During development, simply place the SVG files you need in the specified input folder (default: src/lib/symbol). The plugin will automatically combine them into a single SVG symbol file and output it to the specified output folder (default: static/fonts). After building with Vite, the files in the public folder will be copied to the dist folder. Therefore, after building, the combined SVG symbol file will be located in the dist/fonts folder. Please refer to the Vite Asset Handling documentation.

Default parameters are optimized for SvelteKit projects. If you need to adapt it for non-SvelteKit projects created with Vite, please modify the configuration in vite.config.js or vite.config.ts.

Generally, you can simply place the SVG files in the default input folder without the need for additional configuration.

If you need to modify the input/output folders and the filename of the combined file, or if you need to combine multiple folders, you can customize the configuration in vite.config.js or vite.config.ts:

// ...
    svgSprite([
        { inFile: 'src/lib/svgs', outFile: 'static/fonts', fileName: 'symbol' },
        { inFile: 'src/lib/icons', outFile: 'static/fonts', fileName: 'icon' },
    ]),
// ...

This configuration will combine two symbols. When using the STDF Icon component, please update the path to the corresponding fonts/symbol.svg or fonts/icon.svg.

Note: The parameter should be an array representing the configuration for multiple folders. Each folder configuration should be an object with inFile as the folder where the SVG files to be combined are located, outFile as the output path for the combined SVG symbol file, and fileName as the filename of the combined SVG symbol file (if not passed, the last folder name of inFile will be used). Please ensure the correctness and avoid conflicts in paths and filenames.

In general, the use of symbols is to combine a series of small, single-color SVG files into one symbol. This allows for easy modification of attributes such as color, size, and opacity when using SVG in a project. Therefore, when default configuring rollup-plugin-stdf-icon, the color attributes of the SVG files themselves are removed. If you need to use multi-color SVG files and want to preserve the colors in the generated symbol, you just need to set the simple parameter to false.

Configuration

| Parameter | Default | Description | | --------- | ---------------- | ------------------------------------------------------------------------------------------------------------- | | inFile | 'src/lib/symbol' | The folder where all the SVG files to be merged are located. | | outFile | 'static/fonts' | The output path for the merged SVG symbol file. | | fileName | '' | The filename of the merged SVG symbol file (if not passed, the last folder name of inFile will be used). | | simple | true | Whether to use the simple mode, the simple mode will remove the color attributes of the SVG files themselves. |

License

This project is licensed under the MIT License. Feel free to use and contribute to this open-source project.