webpack-svgstore-plugin-ng2

2.0.9 • Public • Published

webpack-svgstore-plugin

webpack-svgstore-plugin

Build Status NPM version Code Climate Test Coverage

Installation

npm i webpack-svgstore-plugin --save-dev

Usage

1. require plugin

//webpack.config.js

var SvgStore = require('webpack-svgstore-plugin');

module.exports = {
  entry: {
    app: path.join(_path, 'platform', 'static', 'js', 'index.js'),
  },
  plugins: [
    new SvgStore(path.join(sourcePath, 'svg', '**/*.svg'), path.join(distPath, 'svg'), {
      name: '[hash].sprite.svg',
      chunk: 'app',
      baseUrl: '//path-to-cdn:port/'
      prefix: 'myprefix-',
      svgoOptions: {
        // options for svgo, optional
      }
    })
  ]
}

name - sprite name

chunk - add xhr to entry point chunk (optional)

baseUrl - server where the sprites are stored, for example a CDN (optional, default: 'window.location' OR window.baseUrl if set)

prefix - add prefix to svg id's (optional, default: 'icon-')

svgoOtions - options for svgo (optional, default: {})

2. HTML code for happy using

  <svg class="svg-icon">
    <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#icon-name"></use>
  </svg>

License

NPM package avaliable here: webpack-svgstore-plugin

MIT © Chernobrov Mike, Gordey Levchenko

Readme

Keywords

none

Package Sidebar

Install

npm i webpack-svgstore-plugin-ng2

Weekly Downloads

0

Version

2.0.9

License

MIT

Last publish

Collaborators

  • mk9