2.1.0 • Published 6 years ago

@dicebear/avatars-webpack-loader v2.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

Build Status npm

This package provides a webpack loader for Avatars sprite collections.

Installation

npm install --save-dev @dicebear/avatars-webpack-loader

Usage

Create an SVG file with uniquely named groups on the first level. You can access these groups later with the Loader. These groups represent a sprite group, such as the eyes of a character.

The uniquely named groups must contain other groups, which each display a variation. (For example, a variation of the eyes.)

// webpack.config.js

module.exports = {
  // ...
  resolve: {
    extensions: ['.js', '.svg']
  },
  module: {
    rules: [{ test: /\.svg$/, exclude: /node_modules/, loader: '@dicebear/avatars-webpack-loader' }]
  }
  // ...
};

Now you can load your sprite collection SVG files in your JS file.

// sprites.js

import * as svg from 'sprites.svg';

export default new SpriteCollection([
  new Sprite(svg.eyes, colors)
  // ...
]);

Related