All Projects → jpkleemans → vite-svg-loader

jpkleemans / vite-svg-loader

Licence: MIT License
Vite 2.x plugin to load SVG files as Vue components

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to vite-svg-loader

vue3-demo
💡 vue3新特性示例: 响应式API、组合式API、TodoMVC
Stars: ✭ 114 (-8.06%)
Mutual labels:  vite
react-antd-low-code
简易版 react 低代码平台
Stars: ✭ 45 (-63.71%)
Mutual labels:  vite
vue-3-stackter
A Vue3 starter project setup with Vite, Vue-meta, Router, Vuex, Eslint, Prettier, Tailwind CSS, and some custom preferences. Also, there is a TypeScript branch of this same setup.
Stars: ✭ 93 (-25%)
Mutual labels:  vite
peeky
A fast and fun test runner for Vite & Node 🐈️ Powered by Vite ⚡️
Stars: ✭ 611 (+392.74%)
Mutual labels:  vite
vue3-realworld-example-app
Explore the charm of Vue composition API! Vite?
Stars: ✭ 364 (+193.55%)
Mutual labels:  vite
giraffe
📰 Free news, blogs or magazines application theme, built with Vite & Vuetify created by HeroUI.
Stars: ✭ 46 (-62.9%)
Mutual labels:  vite
vite-elm-template
A default template for building Elm applications using Vite.
Stars: ✭ 42 (-66.13%)
Mutual labels:  vite
vitawind
Install and Setting Tailwindcss automatically for Vite
Stars: ✭ 46 (-62.9%)
Mutual labels:  vite
vite-plugin-env-compatible
Environment Variables Compatible for vite(with vue-cli, create-react-app and so on)
Stars: ✭ 35 (-71.77%)
Mutual labels:  vite
github-contribution-graph
Add beautiful GitHub contribution/commit graph to your profile README!
Stars: ✭ 37 (-70.16%)
Mutual labels:  vite
vitesse-nuxt-bridge
🏕 Vitesse experience for Nuxt 2 and Vue 2
Stars: ✭ 149 (+20.16%)
Mutual labels:  vite
swappy-one
swappy.one
Stars: ✭ 24 (-80.65%)
Mutual labels:  vite
electron-vite-template
👻 A fast Simple Vite 2, Vue 3 and Electron 13.x template.
Stars: ✭ 56 (-54.84%)
Mutual labels:  vite
vite-plugin-relay
A vite plugin for Relay
Stars: ✭ 44 (-64.52%)
Mutual labels:  vite
vue3.0-template-admin
本项目基于vue3+ElementPlus+Typescript+Vite搭建一套通用的后台管理模板;并基于常见业务场景,抽象出常见功能组件;包括动态菜单,菜单权限、登录、主题切换、国际化、个人中心、表单页、列表页、复制文本、二维码分享等等
Stars: ✭ 500 (+303.23%)
Mutual labels:  vite
vite-vue3-lowcode
vue3.x + vite2.x + vant + element-plus H5移动端低代码平台 lowcode 可视化拖拽 可视化编辑器 visual editor 类似易企秀的H5制作、建站工具、可视化搭建工具
Stars: ✭ 1,309 (+955.65%)
Mutual labels:  vite
vite-react-ts-tailwind-firebase-starter
Starter using Vite + React + TypeScript + Tailwind CSS. And already set up Firebase(v9), Prettier and ESLint.
Stars: ✭ 108 (-12.9%)
Mutual labels:  vite
unplugin
Unified plugin system for Vite, Rollup, Webpack, and more
Stars: ✭ 998 (+704.84%)
Mutual labels:  vite
theme-generator
CSS Color Theme Generator based on Numl.Design theme generator & HSLuv color space 🌈
Stars: ✭ 17 (-86.29%)
Mutual labels:  vite
learn-wasm
🎲 Learning WebAssembly
Stars: ✭ 57 (-54.03%)
Mutual labels:  vite

Vite SVG loader

Vite 2.x plugin to load SVG files as Vue components, using SVGO for optimization.

Version Downloads Tests License

<template>
  <MyIcon />
</template>

<script setup>
import MyIcon from './my-icon.svg'
</script>

Install

npm install vite-svg-loader --save-dev

Setup

vite.config.js

import svgLoader from 'vite-svg-loader'

export default defineConfig({
  plugins: [vue(), svgLoader()]
})

Import params

URL

SVGs can be imported as URLs using the ?url suffix:

import iconUrl from './my-icon.svg?url'
// '/assets/my-icon.2d8efhg.svg'

Raw

SVGs can be imported as strings using the ?raw suffix:

import iconRaw from './my-icon.svg?raw'
// '<?xml version="1.0"?>...'

Component

SVGs can be explicitly imported as Vue components using the ?component suffix:

import IconComponent from './my-icon.svg?component'
// <IconComponent />

SVGO Configuration

vite.config.js

svgLoader({
  svgoConfig: {
    multipass: true
  }
})

Disable SVGO

vite.config.js

svgLoader({
  svgo: false
})

Use with TypeScript

If you use the loader in a Typescript project, you'll need to import your svg files with the ?component param: import MyIcon from './my-icon.svg?component'.

You'll also need to reference the type definitions:

/// <reference types="vite-svg-loader" />
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].