rollup-plugin-vue-inline-svg

convert svg files to optimised vue components
21,881
Install
npm install rollup-plugin-vue-inline-svg
Latest Version:1.1.2
Vue:2
License:ISC
Last Updated:Mar 7, 2021
Links: npm
Maintainer: e-e-e

rollup-plugin-vue-inline-svg

Unit tests

A simple plugin to import svg files as vue components. This is intended to be used with rollup-plugin-vue and is based on vue-svg-loader.

installation

npm install --save-dev rollup-plugin-vue-inline-svg

usage

rollup.config.js

import svg from 'rollup-plugin-vue-inline-svg';
import vue from 'rollup-plugin-vue'; // optional

export default {
  // ...
  plugins: [
    svg(config)
    vue(), // optional
  ]
}

config

By default this plugin will attempt to transform all files that end with the extension .svg. You can be more explicit by passing include and exclude options.

// `include` and `exclude` can each be a minimatch
// pattern, or an array of minimatch patterns, relative to process.cwd()
{
  include: string or array of minimatch,
  exclude: string or array,
  svgoConfig: svgo config object,
}

See SVGO for configuration options that it accepts.

Import svgs from node_modules

The plugin is able to import svg files from node_modules packages:

import AlertSvg from 'octicons/build/svg/alert.svg'

The only important thing to remember is that the rollup build process needs to be started from the project root directory (e.g. via npm scripts). This is because the plugin will search the node_modules directory, via the process.cwd() node method, from where the process has started.

Related Packages

rollup-plugin-svg-sprites

Rollup plugin for creating SVG sprites.

16,919
vue-cli-plugin-svg-loader

Vue CLI plugin that adds vue-svg-loader to enable usage of SVG files as Vue comp...

1,265 0
vue-sfc-loader

vue sfc loader for browser

9,765
@21cnfe/onekit-mp-cli

小程序框架开发工具

1,063
rollup-plugin-htmlvue

Rollup plugin for transforming HTML/XML to Vue SFC

988 3

Version History

Version Released License
1.1.2 ISC
1.1.1 ISC
1.1.0 ISC
1.0.1 ISC
1.0.0 ISC