GithubHelp home page GithubHelp logo

webpack-vector-sprite-plugin's Introduction

WEBPACK PLUGIN

███████╗██╗   ██╗ ██████╗     ███████╗████████╗ ██████╗ ██████╗ ███████╗
██╔════╝██║   ██║██╔════╝     ██╔════╝╚══██╔══╝██╔═══██╗██╔══██╗██╔════╝
███████╗██║   ██║██║  ███╗    ███████╗   ██║   ██║   ██║██████╔╝█████╗  
╚════██║╚██╗ ██╔╝██║   ██║    ╚════██║   ██║   ██║   ██║██╔══██╗██╔══╝  
███████║ ╚████╔╝ ╚██████╔╝    ███████║   ██║   ╚██████╔╝██║  ██║███████╗
╚══════╝  ╚═══╝   ╚═════╝     ╚══════╝   ╚═╝    ╚═════╝ ╚═╝  ╚═╝╚══════╝                                                                     

NPM

Package info

Build Status NPM version

Installation

npm i webpack-vector-sprite-plugin --save-dev

Webpack version support

Use [email protected] for Webpack 1.x.x
Use [email protected] for Webpack 2.x.x,3.x.x,4.x.x.

Node.js version support

We do not maintain a version for node.js 0.12 anymore

Tested to work with with node.js 4.x,6.x,7.x,8.x

Webpack configuration

EXAMPLE here

Usage

1) require plugin

//webpack.config.js
var SvgStore = require('webpack-vector-sprite-plugin');
module.exports = {
  plugins: [
    // create svgStore instance object
    new SvgStore({
      // svgo options
      svgoOptions: {
        plugins: [
          { removeTitle: true }
        ]
      },
      prefix: 'icon'
    })
  ]
}

2) Put function mark at your chunk

// plugin will find marks and build sprite

var __svg__           = { path: './assets/svg/**/*.svg', name: 'assets/svg/[hash].logos.svg' };
// will overwrite to var __svg__ = { filename: "assets/svg/1466687804854.logos.svg" };

// also you can use next variables for sprite compile
// var __sprite__     = { path: './assets/svg/minify/*.svg', name: 'assets/svg/[hash].icons.svg' };
// var __svgstore__   = { path: './assets/svg/minify/*.svg', name: 'assets/svg/[hash].stuff.svg' };
// var __svgsprite__  = { path: './assets/svg/minify/*.svg', name: 'assets/svg/[hash].1logos.svg' };

// require basic or custom sprite loader
require('webpack-vector-sprite-plugin/src/helpers/svgxhr')(__svg__);
Dear friends...

As you know, last version has integrated ajax sprite loader. Right now, you can override that. Or create your own sprite ajax loader function.

3) HTML code for happy using

HTML:

  <svg class="svg-icon">
    <use xlink:href="#icon-name"></use>
  </svg>

React JSX:

  <svg className='svg-icon'>
    <use xlinkHref='#icon-name' />
  </svg>

Plugin settings

options

  • template - add custom jade template layout (optional)
  • svgoOptions - options for svgo (optional, default: {})

License

NPM package available here: webpack-vector-sprite-plugin

MIT © Chernobrov Mike, Gordey Levchenko , Nadav Sinai , Zack Jackson

webpack-vector-sprite-plugin's People

Contributors

af avatar alexlande avatar dependabot[bot] avatar ggarek avatar ianmstew avatar iptpv avatar jstcki avatar lgordey avatar limpbrains avatar matpaul avatar melloc01 avatar mk0x9 avatar mrsum avatar mshustov avatar nadavsinai avatar nadavspi avatar nevech avatar oller avatar pmeinhardt avatar rlebosse avatar ryan-codingintrigue avatar scriptedalchemy avatar

Stargazers

 avatar

Watchers

 avatar

webpack-vector-sprite-plugin's Issues

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.