Core asset-toolkit
npm install @asset-toolkit/core@asset-toolkit/core / Exports
- changeExtension
- checkFileExt
- copyFiles
- getUID
- logger
- pipeline
- prepareOutputDir
- watchPipeline
• Const removeDir: any
#### Defined in
index.d.ts:1
▸ Const changeExtension(file, extension): string
#### Parameters
| Name | Type |
| :------ | :------ |
| file | string |
| extension | string |
#### Returns
string
#### Defined in
index.d.ts:22
___
▸ Const checkFileExt(file, exts): boolean
#### Parameters
| Name | Type |
| :------ | :------ |
| file | string |
| exts | string[] |
#### Returns
boolean
#### Defined in
index.d.ts:8
___
▸ Const copyFiles(pathIn, pathOut, exts?): void
#### Parameters
| Name | Type |
| :------ | :------ |
| pathIn | string |
| pathOut | string |
| exts? | string[] |
#### Returns
void
#### Defined in
index.d.ts:9
___
▸ Const getUID(size): any
#### Parameters
| Name | Type |
| :------ | :------ |
| size | number |
#### Returns
any
#### Defined in
index.d.ts:11
___
▸ Const logger(): Object
#### Returns
Object
| Name | Type |
| :------ | :------ |
| error | (value: any) => any |
| info | (value: any) => any |
| start | (value: any) => any |
| success | (value: any) => any |
#### Defined in
index.d.ts:2
___
▸ Const pipeline(...fns): (props: any, options: any[], callback?: any[]) => any
#### Parameters
| Name | Type |
| :------ | :------ |
| ...fns | any |
#### Returns
fn
▸ (props, options, callback?): any
##### Parameters
| Name | Type |
| :------ | :------ |
| props | any |
| options | any[] |
| callback? | any[] |
##### Returns
any
#### Defined in
index.d.ts:12
___
▸ Const prepareOutputDir(pathOut, exts): void
#### Parameters
| Name | Type |
| :------ | :------ |
| pathOut | string |
| exts | string[] |
#### Returns
void
#### Defined in
index.d.ts:10
___
▸ Const watchPipeline(pipeline, props, options?, callback?): void
#### Parameters
| Name | Type |
| :------ | :------ |
| pipeline | any |
| props | Object |
| props.pathIn | string |
| props.pathOut | string |
| options? | any[] |
| callback? | any[] |
#### Returns
void
#### Defined in
index.d.ts:13
Node.js toolkits to optimize media assets.
A pipe function to concatenate toolkits.
``js
const { pipeline } = require('@asset-toolkit/core')
const pipelineExample = pipeline(...fn)
pipelineExample({
pathIn: './exampleIn/',
pathOut: '../../exampleOut/',
})
`
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.
`bash`
npm i
@asset-toolkit/core
@asset-toolkit/audio-sprite
@asset-toolkit/json-minify
`js`
const { pipeline } = require('@asset-toolkit/core')
const audioSprite = require('@asset-toolkit/audio-sprite')
const jsonMinify = require('@asset-toolkit/json-minify')
`js
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,
)
`
For relaunch automatically your pipeline everytime you add or modify the files in input folder.
`js`
const { pipeline, watchPipeline } = require('@asset-toolkit/core')
const jsonMinify = require('@asset-toolkit/json-minify')
`js
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',
})
`
Create a js file "example.js", with your code (import and configure the pipelines like examples).
Run your code with node: node example.js`