# spine-loader

> Webpack loader for spine-animations

Latest version **1.0.2** (published 2021-11-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install spine-loader
pnpm add spine-loader
yarn add spine-loader
bun add spine-loader
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2021-11-22 |
| First published | 2021-11-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 9.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Anton Pavlov |
| Maintainers | aapavlov1994 |
| Keywords | webpack, loader, spine, animation |

## Links

- npm: https://www.npmjs.com/package/spine-loader
- Repository: https://github.com/aapavlov1994/spine-loader
- Homepage: https://github.com/aapavlov1994/spine-loader#readme
- Issues: https://github.com/aapavlov1994/spine-loader/issues
- npm.io page: https://npm.io/package/spine-loader

## Dependencies (2)

- [find-cache-dir](https://npm.io/package/find-cache-dir.md) ^3.3.2
- [multi-sprite-creator](https://npm.io/package/multi-sprite-creator.md) ^2.0.0

## Alternatives

- [@luma.gl/experimental](https://npm.io/package/@luma.gl/experimental.md) — 77.1K weekly downloads
- [persona-harness](https://npm.io/package/persona-harness.md) — 4.7K weekly downloads
- [@tsparticles/effect-bubble](https://npm.io/package/@tsparticles/effect-bubble.md) — 4.6K weekly downloads
- [f3d](https://npm.io/package/f3d.md) — 730 weekly downloads
- [spark-html-motion](https://npm.io/package/spark-html-motion.md) — 298 weekly downloads

## Recent versions

- 1.0.2 (latest) — 2021-11-22
- 1.0.1 — 2021-11-18
- 1.0.0 — 2021-11-17

## README

# spine-loader
Webpack loader for configuring spine-animations

### Usage

`npm i spine-loader --save-dev`

```javascript
// webpack config
rules.push({
  type: 'javascript/auto',
  test: /\.json$/,
  include: /spine/,
  loader: 'spine-loader',
});

// some place in src
const configFromJSON = require('@/assets/spine/goblin/index.json')

// output
configFromJSON.skeleton.sprite.src // sprite image
configFromJSON.skeleton.sprite.map // sprite map string
// also you can check your sprite in
// node_modules/.cache/spine-loader

// example usage with PIXI and Spine plugin
const { src, map } = configFromJSON.skeleton.sprite;
const img = document.createElement('img');
img.setAttribute('src', src);
img.onload = () => {
  const spineAtlas = new PIXI.spine
    .TextureAtlas(map, (line, callback) => {
      callback(PIXI.Texture.from(img).baseTexture);
    });

  const spineAtlasLoader = new PIXI.spine.AtlasAttachmentLoader(spineAtlas);
  const spineJsonParser = new PIXI.spine.SkeletonJson(spineAtlasLoader);

  const spineData = spineJsonParser.readSkeletonData(configFromJSON);
  spineData.initScale = configFromJSON.skeleton.scale;

  const spineAnim = new PIXI.spine.Spine(spineData); // your animation instance
  spineAnim.scale.set(spineData.initScale);
};
```

A typical structure of file with animations should
look like (separate assets in "images" subdirs
near with single json file):

![img.png](readme_assets/structure.jpg)

### Loader options

There are two additional loader options: scale and skins
for including only useful assets with chosen resolution.

```javascript
// you can specify options like this
rules.push({
  type: 'javascript/auto',
  test: /\.json$/,
  include: /spine/,
  loader: 'spine-loader',
  options: {
    scale: 0.5,
    skins: ['RED_SKIN', 'BLUE_SKIN']
  }
});
// or like this
const configFromJSON = require('@/assets/spine/goblin/index.json?{"scale":0.2}')
```

---
_Source: https://npm.io/package/spine-loader · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
