Git Product home page Git Product logo

rollup-plugin-vue-inline-svg's Introduction

rollup-plugin-vue-inline-svg

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.

This fork:

  • Let's rollup-plugin-vue compile the svg vue templates, make sure to configure rollup-plugin-vue as following: { include: [/\.vue$/i, /\.svg$/i] } (so that it also compiles the transformed svg files)
  • Makes the templates functional

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.

rollup-plugin-vue-inline-svg's People

Contributors

e-e-e avatar arcomul avatar rdunk avatar

Watchers

James Cloos avatar

Forkers

amoramishvili

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.