@asset-toolkit/image-sprite
TypeScript icon, indicating that this package has built-in type declarations

0.5.8 • Public • Published

@asset-toolkit/image-sprite / Exports

@asset-toolkit/image-sprite

Table of contents

Type aliases

Functions

Type aliases

options

Ƭ options: Object

Type declaration

Name Type
algorithm? string
customFormat? string
format? string
fullpath? boolean
fuzz? string
group? string[]
gutter? number
height? number
maxAtlases? number
name? string
padding? number
powerOfTwo? boolean
prefix? string
resizeHeight? number
resizeWidth? number
scale? string
size? number
sort? string
square? boolean
trim? boolean
width? number

Defined in

index.d.ts:1


props

Ƭ props: Object

Type declaration

Name Type
pathIn? string
pathOut string

Defined in

index.d.ts:24


returns

Ƭ returns: Object

Type declaration

Name Type
pathOut string

Defined in

index.d.ts:28

Functions

default

Const default(_props, _options?): Promise<returns>

Parameters

Name Type
_props props
_options? options

Returns

Promise<returns>

Defined in

index.d.ts:31

Asset ToolKits

Node.js toolkits to optimize media assets.

Use a pipeline

A pipe function to concatenate toolkits.

const { pipeline } = require('@asset-toolkit/core')

const pipelineExample = pipeline(...fn)

pipelineExample({
  pathIn: './exampleIn/',
  pathOut: '../../exampleOut/',
})

Example with pipeline

With audio-sprite and json-minify tools. Use the function returned from pipeline to pass props and options.

The options is an array of object. Every object is linked to tools function passed to pipeline by our order.

npm i
@asset-toolkit/core
@asset-toolkit/audio-sprite
@asset-toolkit/json-minify
const { pipeline } = require('@asset-toolkit/core')
const audioSprite = require('@asset-toolkit/audio-sprite')
const jsonMinify = require('@asset-toolkit/json-minify')
const options = [
  {
    output: 'spriteTrack',
    export: 'mp3, m4a',
  },
] // first argument for first tool in pipeline

const pipelineAudio = pipeline(audioSprite, jsonMinify)

pipelineAudio(
  {
    pathIn: './audio/',
    pathOut: '../public/audio',
  },
  options,
)

Example with watcher

For relaunch automatically your pipeline everytime you add or modify the files in input folder.

const { pipeline, watchPipeline } = require('@asset-toolkit/core')
const jsonMinify = require('@asset-toolkit/json-minify')
const options = [
  {
    output: 'spriteTrack',
    export: 'mp3, m4a',
  },
] // first argument for first tool in pipeline

const pipelineJSON = pipeline(jsonMinify)

watchPipeline(pipelineJSON, {
  pathIn: './json/',
  pathOut: '../public/json',
})

How to use

Create a js file "example.js", with your code (import and configure the pipelines like examples).

Run your code with node: node example.js

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @asset-toolkit/image-sprite

Weekly Downloads

0

Version

0.5.8

License

none

Unpacked Size

33 kB

Total Files

16

Last publish

Collaborators

  • aquestdigital