4.2.0 • Published 1 year ago

vite-plugin-svgr v4.2.0

Weekly downloads
188
License
MIT
Repository
github
Last release
1 year ago

vite-plugin-svgr

npm

Vite plugin to transform SVGs into React components. Uses svgr under the hood.

Installation

# npm
npm install --save-dev vite-plugin-svgr

# yarn
yarn add -D vite-plugin-svgr

# pnpm
pnpm add -D vite-plugin-svgr

Usage

// vite.config.js
import svgr from "vite-plugin-svgr";

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

Then SVG files can be imported as React components:

import Logo from "./logo.svg?react";

If you are using TypeScript, there is also a declaration helper for better type inference:

/// <reference types="vite-plugin-svgr/client" />

Options

svgr({
  // svgr options: https://react-svgr.com/docs/options/
  svgrOptions: {
    // ...
  },

  // esbuild options, to transform jsx to js
  esbuildOptions: {
    // ...
  },

  // A minimatch pattern, or array of patterns, which specifies the files in the build the plugin should include.
  include: "**/*.svg?react",

  //  A minimatch pattern, or array of patterns, which specifies the files in the build the plugin should ignore. By default no files are ignored.
  exclude: "",
});

If you want to enable SVGO you can install @svgr/plugin-svgo and use following options to enable and configure it:

svgr({
  svgrOptions: {
    plugins: ["@svgr/plugin-svgo", "@svgr/plugin-jsx"],
    svgoConfig: {
      floatPrecision: 2,
    },
  },
  // ...
});

License

MIT

@une/cli@inv3rse/react-sdkhorizon-design-system@infinitebrahmanuniverse/nolb-vite-plugin-s@nexatlas-os/nexds-webcro-joon-frontend-components-storymy-first-library-for@yamcodes/uiplop-dms@everything-registry/sub-chunk-3061cloud-air-components@beardeddudes-dev/vite@beardeddudes-dev/vite-configgic_frontendfireflink-ui-test-ubaidtalentorg-profile-editortawuniya-uitable-react-component-librarytailwind-adminterho-new-buttonswallaby-uitermblocktest-foton-v2test-gugassswaggle-design-systemxing-react-uixmluisupertonestores_in_store_test_npmtesting-test-testesttest-web-shared-componentsteste-gugassssvag-vitevpdchatbottestvite-template-reactvite-config-preset@graphiql/plugin-utils@dripui/react@cro-project/cro-frontend-components@cryptohubltd/kyberswap-widget@conboai/storybook.components@dimitar.n.vasilev/file-explorer@buttery/tools@bpa-dev/react-uikit@performer/playground@rsh-axelor/timer-builder@rokid-library/componentsipts-ds-system-demojusta-clientkvikna-designsystemkyberswap-widgetsados-components@shop-one/builder-utilsfoton-v2spacer-ui-componentsspacer-ui-kitstitch-component-clitk-noteuikit-inctagramui-kit-pma1ui-library-rodrigotrack-1-design-systemtownesquare-connectauthtrainporttrainport-uitrendmet-ui-kituser-sentiments@armco/components@armco/armory-react-components@appkit/dek-lib@asigna/btc-connect@ariga/atlas-website@beardeddudes/vite-config@axos-web-dev/shared-components@big-components/ui@bixi-design/builder@bitfinity-network/bridge-widget@bn-digital/vite@chieftayn/automation-designer@civic/react-commons@civic/civic-link@clarke-energia/foton@clarke-energia/foton-v2@denindka/editor-dsd@darkobits/tsxxverse-iconyui-uikitvikas-ui@fosforescent/react-client@hrnet-aj/data-table@elyspio/vite-eslint-config@emilgadzhiyev/tree-menu@inftech/ui@itwin/synchronization-report-react@macellan/dux-components@macellan/dux-core@magic-circle/editor@movn/ui-library@msafe/msafe-ui@murui/com-design
4.2.0

1 year ago

3.3.0

2 years ago

4.1.0

2 years ago

4.0.0

2 years ago

3.2.0

2 years ago

3.1.0

2 years ago

3.0.0

2 years ago

2.3.0

2 years ago

2.4.0

2 years ago

2.2.2

3 years ago

2.2.1

3 years ago

2.2.0

3 years ago

2.1.1

3 years ago

2.1.0

3 years ago

2.0.0

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.5.0

3 years ago

0.6.0

3 years ago

0.5.1

3 years ago

0.4.0

4 years ago

0.3.0

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago

0.0.1

4 years ago