vite-plugin-svg-inject

1.2.0 • Public • Published

⚙️ Vite plugin SVG inject

Npm package version Small size

Inject SVG content into components

.

  • Install

npm i vite-plugin-svg-inject -D
  • Configure

import { defineConfig } from "vite";
import SVGInjectPlugin from "vite-plugin-svg-inject";

export default defineConfig({
  plugins: [
    // Target:
    // - "react" - If JSX library is React
    // - "other" (default) - For others libraries
    SVGInjectPlugin(target)
  ],
})
  • Example

import MyIcon from './images/icon.svg';

function MyComponent() {
  return (
    <div>
      <MyIcon width="32" fill="red" />
    </div>
  );
}

Package Sidebar

Install

npm i vite-plugin-svg-inject

Weekly Downloads

26

Version

1.2.0

License

MIT

Unpacked Size

3.79 kB

Total Files

5

Last publish

Collaborators

  • neki-development