### Install Project Dependencies Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/README.md Installs all project dependencies required for development and production. This command should be run in the root directory of the project. ```bash yarn ``` -------------------------------- ### PixiJS Pre-configured Setup Source: https://context7.com/pixijs/assetpack/llms.txt Provides an opinionated, pre-configured setup for PixiJS projects using `pixiPipes`, including common plugins for cache busting, resolutions, compression, texture packing, and manifest generation. ```APIDOC ## PixiJS Pre-configured Setup ### Description Provides an opinionated, pre-configured setup for PixiJS projects using `pixiPipes`, including common plugins for cache busting, resolutions, compression, texture packing, and manifest generation. ### Method Configuration within AssetPack ### Endpoint N/A ### Parameters #### Request Body Options - **cacheBust** (boolean) - Enable cache busting. - **resolutions** (object) - Defines asset resolutions (e.g., `{ default: 1, low: 0.5 }`). - **compression** (object) - Compression settings for various image formats (e.g., `{ jpg: true, png: true, webp: true, avif: false }`). - **texturePacker** (object) - Texture packer options (e.g., `{ nameStyle: "short", padding: 2 }`). - **audio** (object) - Audio processing options. - **manifest** (object) - Manifest generation options (e.g., `{ createShortcuts: true, trimExtensions: false }`). ### Request Example ```javascript import { pixiPipes } from "@assetpack/core/pixi"; export default { entry: './raw-assets', output: './public/assets', pipes: [ ...pixiPipes({ cacheBust: true, resolutions: { default: 1, low: 0.5 }, compression: { jpg: true, png: true, webp: true, avif: false, }, texturePacker: { nameStyle: "short", padding: 2, }, audio: {}, manifest: { createShortcuts: true, trimExtensions: false, }, }), ], }; ``` ### Response #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Start Local Development Server Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/README.md Initializes a local development server with hot-reloading capabilities. Changes made to source files are reflected in the browser without requiring a server restart. ```bash yarn start ``` -------------------------------- ### PixiJS Setup with AssetPack Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/docs/guide/getting-started/pixi.md This snippet demonstrates how to configure AssetPack for PixiJS using the `pixiPipes` function. It includes common options for cache busting, resolutions, compression, texture packing, audio processing, and manifest creation. ```APIDOC ## PixiJS Setup with AssetPack ### Description This section outlines the configuration options available when integrating AssetPack with PixiJS. The `pixiPipes` function provides a convenient way to set up asset processing pipelines tailored for PixiJS applications. ### Method `pixiPipes(options)` ### Endpoint N/A (This is a configuration function, not an API endpoint) ### Parameters #### Request Body (Options Object) - **cacheBust** (boolean) - Optional - Whether to append a cache-busting query string to the asset URLs. Defaults to `true`. - **resolutions** (Record) - Optional - A map of resolution names to scaling factors. Defaults to `{ default: 1, low: 0.5 }`. - **compression** (CompressOptions | false) - Optional - Options for compressing the output files. Defaults to `{ jpg: true, png: true, webp: true }`. - **texturePacker** (TexturePackerOptions) - Optional - Options for generating texture atlases. Defaults to `{ texturePacker: { nameStyle: 'short' }}`. - **audio** (Partial) - Optional - Options for compressing audio files. Defaults to `{}`. - **manifest** (PixiManifestOptions) - Optional - Options for generating a PixiJS manifest file. Defaults to `{ createShortcuts: true }`. ### Request Example ```js import { pixiPipes } from "@assetpack/core/pixi"; export default { // ... other configurations pipes: [ ...pixiPipes({ cacheBust: true, resolutions: { default: 1, low: 0.5 }, compression: { jpg: true, png: true, webp: true }, texturePacker: { nameStyle: "short" }, audio: {}, manifest: { createShortcuts: true }, }), ], }; ``` ### Response This function returns an array of pipes to be used within the AssetPack configuration. No direct response body is applicable as it's part of the AssetPack setup. #### Success Response (N/A) N/A #### Response Example (N/A) N/A ``` -------------------------------- ### Setup GitHub Action Workflow for AssetPack Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/docs/guide/getting-started/github-action.md This YAML workflow configures a GitHub Action to check out code, set up Node.js, install dependencies, cache AssetPack related directories, and run the build script. It utilizes caching to store and restore the `.assetpack` and `raw-assets` directories based on file hashes and package lock files. ```yaml name: AssetPack on: [push] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '20' - name: Install dependencies run: npm ci # Cache assets! - name: Generate hash from file names id: hash-names run: echo "NAMES_HASH=$(find ./raw-assets -type f | sort | md5sum | cut -d' ' -f1)" >> $GITHUB_ENV - name: Cache .assetpack directory id: cache-directory uses: actions/cache@v4 with: path: | .assetpack raw-assets key: ${{ runner.os }}-cache-23-04-24-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('raw-assets/**/*') }}-${{ env.NAMES_HASH }} restore-keys: | ${{ runner.os }}-cache-23-04-24-${{ hashFiles('**/package-lock.json') }} # End Cache assets! # Now do your build - name: Build run: npm run build ``` -------------------------------- ### Configure Spine Atlas Plugins Source: https://context7.com/pixijs/assetpack/llms.txt This setup processes Spine animation atlas files by applying compression and mipmap generation. It ensures the manifest is updated to reflect the processed Spine assets. ```javascript import { compress, mipmap } from "@assetpack/core/image"; import { spineAtlasCompress, spineAtlasMipmap, spineAtlasManifestMod } from "@assetpack/core/spine"; import { pixiManifest } from "@assetpack/core/manifest"; const compressOptions = { png: { quality: 90 }, webp: { quality: 80 } }; const mipmapOptions = { template: "@%%x", resolutions: { default: 1, low: 0.5 } }; export default { entry: './raw-assets', output: './public/assets', pipes: [ mipmap(mipmapOptions), spineAtlasMipmap(mipmapOptions), compress(compressOptions), spineAtlasCompress(compressOptions), pixiManifest(), spineAtlasManifestMod(), ], }; ``` -------------------------------- ### PixiJS AssetPack Configuration Example Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/docs/guide/getting-started/pixi.md This code snippet demonstrates how to configure AssetPack for PixiJS, utilizing the pixiPipes function. It shows how to pass various options such as cacheBust, resolutions, compression, texturePacker, audio, and manifest settings to customize the asset pipeline. ```javascript import { pixiPipes } from "@assetpack/core/pixi"; export default { ... pipes: [ ...pixiPipes({ cacheBust: true, resolutions: { default: 1, low: 0.5 }, compression: { jpg: true, png: true, webp: true }, texturePacker: { nameStyle: "short" }, audio: {}, manifest: { createShortcuts: true }, }), ], }; ``` -------------------------------- ### Configure PixiJS Pre-configured Setup Source: https://context7.com/pixijs/assetpack/llms.txt The pixiPipes function provides an opinionated, all-in-one configuration for PixiJS projects, simplifying the setup of common plugins like cache busting, compression, and manifest generation. ```javascript import { pixiPipes } from "@assetpack/core/pixi"; export default { entry: './raw-assets', output: './public/assets', pipes: [ ...pixiPipes({ cacheBust: true, resolutions: { default: 1, low: 0.5 }, compression: { jpg: true, png: true, webp: true, avif: false }, texturePacker: { nameStyle: "short", padding: 2 }, audio: {}, manifest: { createShortcuts: true, trimExtensions: false }, }), ], }; ``` -------------------------------- ### Install AssetPack Core Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/docs/guide/getting-started/installation.mdx Installs the core AssetPack package as a development dependency using npm. ```bash npm install --save-dev @assetpack/core ``` -------------------------------- ### AssetPack Configuration Example Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/docs/guide/configuration.md This JavaScript configuration file defines the behavior of AssetPack. It specifies input and output directories, files to ignore, caching options, logging level, and custom asset processing rules for different file types. ```javascript export default { entry: './raw-assets', output: './public', ignore: ['**/*.html'], cache: true, cacheLocation: '.assetpack', logLevel: 'info', pipes: [ // Pipes go here ], assetSettings: [ { files: ['**/*.png'], settings: { compress: { jpg: true, png: true, // all png files will be compressed to avif format but not webp webp: false, avif: true, }, }, }, ], }; ``` -------------------------------- ### Configure Texture Packer Compression with Sharp Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/docs/guide/pipes/texture-packer.mdx This example demonstrates how to configure the texturePackerCompress plugin to compress texture atlases using the Sharp library. It shows how to set options for various image formats like JPG, PNG, WebP, and AVIF, and also includes support for advanced compression standards like BC7, ASTC, Basis, and ETC. Ensure that the options passed to the 'compress' plugin are identical to those used for 'texturePackerCompress'. ```javascript import { compress } from "@assetpack/core/image"; import { texturePackerCompress } from "@assetpack/core/texture-packer"; // these options are the default values, all options shown here are optional const options = { jpg: {}, png: { quality: 90 }, webp: { quality: 80, alphaQuality: 80, }, avif: false, bc7: false, astc: false, basis: false, etc: false }; export default { ... pipes: [ ... compress(options), texturePackerCompress(options), ] }; ``` -------------------------------- ### Initialize and Execute AssetPack Programmatically Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/docs/guide/getting-started/programmatic.md Demonstrates how to import the AssetPack class, configure paths and pipes, and control the execution lifecycle using run, watch, and stop methods. ```javascript import { AssetPack } from '@assetpack/core'; const assetpack = new AssetPack({ entry: './raw-assets', output: './public/assets', pipes: [], }); // To run AssetPack await assetpack.run(); // Or to watch the assets directory for changes void assetpack.watch(); // To stop watching the assets directory assetpack.stop(); ``` -------------------------------- ### Programmatic AssetPack Initialization and Execution Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/docs/guide/getting-started/programmatic.md This snippet demonstrates how to import the AssetPack class, initialize it with configuration options, and then run or watch your assets. ```APIDOC ## Programmatic AssetPack Usage ### Description AssetPack can be run programmatically, allowing you to integrate its functionality directly into your own scripts for custom build processes or asset management. ### Method Instantiate and call methods on the `AssetPack` class. ### Endpoint N/A (Programmatic API) ### Parameters #### Initialization Options - **entry** (string) - Required - The path to your raw assets directory. - **output** (string) - Required - The directory where processed assets will be saved. - **pipes** (array) - Optional - An array of pipe configurations to process assets. ### Request Example ```javascript import { AssetPack } from '@assetpack/core'; const assetpack = new AssetPack({ entry: './raw-assets', output: './public/assets', pipes: [], }); // To run AssetPack once await assetpack.run(); // To watch the assets directory for changes void assetpack.watch(); // To stop watching the assets directory // assetpack.stop(); ``` ### Response N/A (Programmatic execution) ### Error Handling Refer to the AssetPack core documentation for specific error handling related to initialization or execution. ``` -------------------------------- ### Build Project for Production Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/README.md Compiles the website into static files stored in the build directory. These files are optimized for deployment to any static content hosting service. ```bash yarn build ``` -------------------------------- ### Configure FFmpeg Plugin Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/docs/guide/pipes/ffmpeg.mdx Shows how to use the FFmpeg plugin to define custom input formats and specific output configurations, including bitrate and channel settings. ```typescript // assetpack.config.ts import { ffmpeg } from "@assetpack/core/ffmpeg"; export default { ... pipes: [ ffmpeg({ inputs: ['.mp3', '.ogg', '.wav'], outputs: [ { formats: ['.mp3'], recompress: false, options: { audioBitrate: 96, audioChannels: 1, audioFrequency: 48000, }, }, { formats: ['.ogg'], recompress: false, options: { audioBitrate: 32, audioChannels: 1, audioFrequency: 22050, }, }, ], }), ], }; ``` -------------------------------- ### Configure Audio Plugin Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/docs/guide/pipes/ffmpeg.mdx Demonstrates how to integrate the audio plugin into the AssetPack configuration to handle automatic compression of audio files. ```typescript // assetpack.config.ts import { audio } from "@assetpack/core/ffmpeg"; export default { ... pipes: [ audio: audio(), ], }; ``` -------------------------------- ### Define AssetPack Configuration with MetaData Tags Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/docs/guide/pipes/overview.mdx Demonstrates how to configure AssetPack and apply tags to specific file patterns using the metaData property, avoiding the need to rename files directly. ```typescript const appConfig: AssetPackConfig = { entry: './assets', assetSettings: [ { files: ['**/images'], metaData: { tps: true, // other tags can be added here } } ], }; ``` -------------------------------- ### Manifest Plugin Source: https://context7.com/pixijs/assetpack/llms.txt Generates a PixiJS-compatible manifest file for easy asset loading with bundles. Supports bundle creation and exclusion rules. ```APIDOC ## Manifest Plugin ### Description Generates a PixiJS-compatible manifest file for easy asset loading with bundles. Supports bundle creation and exclusion rules. ### Method Configuration within AssetPack ### Endpoint N/A ### Parameters #### Request Body Options - **output** (string) - Optional - The name of the manifest file (default: 'manifest.json'). - **createShortcuts** (boolean) - Optional - If true, creates shortcuts for bundles. - **trimExtensions** (boolean) - Optional - If true, trims file extensions from asset names. - **includeMetaData** (boolean) - Optional - If true, includes metadata in the manifest. - **includeFileSizes** (string) - Optional - Specifies which file sizes to include (e.g., 'gzip'). - **nameStyle** (string) - Optional - Style for naming assets (e.g., 'short'). ### Request Example ```javascript import { pixiManifest } from "@assetpack/core/manifest"; export default { entry: './raw-assets', output: './public/assets', pipes: [ // ... other plugins pixiManifest({ output: "manifest.json", createShortcuts: true, trimExtensions: false, includeMetaData: true, includeFileSizes: 'gzip', nameStyle: 'short' }), ], }; ``` ### Response #### Success Response (200) N/A #### Response Example ``` // Use {m} tag on folders to create bundles: // raw-assets/game{m}/level1/ -> bundle: "game" // raw-assets/ui{m}/buttons/ -> bundle: "ui" // Use {mIgnore} to exclude from manifest: // raw-assets/debug{mIgnore}/test.png -> excluded ``` ``` -------------------------------- ### Configure AssetPack Compression Pipeline Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/docs/guide/pipes/compress.mdx This snippet demonstrates how to integrate the compress plugin into an AssetPack configuration. It shows the structure for defining output formats and their respective quality settings. ```javascript import { compress } from "@assetpack/core/image"; export default { ... pipes: [ ... compress({ jpg: {}, png: { quality: 90 }, webp: { quality: 80, alphaQuality: 80, }, avif: false, bc7: false, astc: false, basis: false, etc: false }), ] }; ``` -------------------------------- ### Configure Mipmap Plugin in AssetPack Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/docs/guide/pipes/mipmap.mdx Demonstrates how to integrate the mipmap plugin into an AssetPack configuration file. It shows the default settings and how to define custom resolution scales. ```javascript import { mipmap } from "@assetpack/core/image"; export default { ... pipes: [ ... mipmap({ template: "@%%x", resolutions: { default: 1, low: 0.5 }, fixedResolution: "default", }), ] }; ``` ```javascript import { mipmap } from "@assetpack/core/image"; export default { ... pipes: [ ... mipmap({ resolutions: { high: 2, default: 1, low: 0.5 }, }), ] }; ``` -------------------------------- ### Audio Plugin Configuration Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/docs/guide/pipes/ffmpeg.mdx Configure the audio plugin to convert and compress audio files (mp3, wav, ogg) to mp3 and ogg formats. ```APIDOC ## Audio Plugin Configuration ### Description Configure the audio plugin to convert and compress audio files (mp3, wav, ogg) to mp3 and ogg formats. ### Method Configuration ### Endpoint N/A (Configuration within assetpack.config.ts) ### Parameters This plugin is configured within the `pipes` array of the `assetpack.config.ts` file. ### Request Example ```ts // assetpack.config.ts import { audio } from "@assetpack/core/ffmpeg"; export default { ... pipes: [ audio: audio(), ], }; ``` ### Response N/A (This is a configuration example, not an API endpoint response.) ``` -------------------------------- ### Configure PixiJS Manifest Plugin Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/docs/guide/pipes/manifest.mdx This snippet demonstrates how to integrate the pixiManifest plugin into an AssetPack configuration file. It shows the available configuration options such as output filename, shortcut creation, and metadata inclusion. ```javascript import { pixiManifest } from "@assetpack/core/manifest"; export default { ... pipes: [ ... pixiManifest({ output: "manifest.json", createShortcuts: false, trimExtensions: false, includeMetaData: true, includeFileSizes: false, nameStyle: 'short' }) ], }; ``` -------------------------------- ### Configure AssetPack for PixiJS Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/docs/guide/getting-started/installation.mdx Integrates PixiJS-specific optimization pipes into the AssetPack configuration using the pixiPipes helper function. ```javascript import { pixiPipes } from '@assetpack/core/pixi'; export default { entry: './raw-assets', output: './public/assets', pipes: [ ...pixiPipes({ // PixiJS configuration options }), ], }; ``` -------------------------------- ### Deploy to GitHub Pages Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/README.md Deploys the built website to the gh-pages branch. Supports both SSH and HTTPS authentication methods for GitHub interaction. ```bash USE_SSH=true yarn deploy GIT_USER= yarn deploy ``` -------------------------------- ### CLI Usage and Scripts Source: https://context7.com/pixijs/assetpack/llms.txt Integrate AssetPack into package.json scripts or run it directly via CLI for building or watching assets. ```json { "scripts": { "prebuild": "assetpack", "build": "your-build-command", "watch:assetpack": "assetpack -w", "watch": "npm run watch:assetpack & your-watch-command" } } ``` ```bash npx assetpack npx assetpack -w npx assetpack -c ./config/my-assetpack.js ``` -------------------------------- ### Configure AssetPack Source: https://context7.com/pixijs/assetpack/llms.txt Define the project asset processing pipeline using a .assetpack.js configuration file. This includes setting input/output directories and specific asset processing rules. ```javascript export default { entry: './raw-assets', output: './public/assets', ignore: ['**/*.html'], cache: true, cacheLocation: '.assetpack', logLevel: 'info', strict: false, pipes: [], assetSettings: [ { files: ['**/*.png'], settings: { compress: { jpg: true, png: true, webp: false, avif: true, }, }, metaData: { tps: true, } }, ], }; ``` -------------------------------- ### FFmpeg Plugin for Custom Conversions Source: https://context7.com/pixijs/assetpack/llms.txt Provides direct access to the FFmpeg API for advanced audio and video processing. Allows for fine-grained control over conversion parameters, including input/output formats and compression settings. ```javascript import { ffmpeg } from "@assetpack/core/ffmpeg"; export default { entry: './raw-assets', output: './public/assets', pipes: [ ffmpeg({ inputs: ['.mp3', '.ogg', '.wav'], outputs: [ { formats: ['.mp3'], recompress: false, options: { audioBitrate: 96, audioChannels: 1, audioFrequency: 48000, }, }, { formats: ['.ogg'], recompress: false, options: { audioBitrate: 32, audioChannels: 1, audioFrequency: 22050, }, }, ], }), ], }; ``` -------------------------------- ### FFmpeg Plugin Configuration Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/docs/guide/pipes/ffmpeg.mdx Configure the FFmpeg plugin to utilize the full FFmpeg API for converting any file type to any other file type. ```APIDOC ## FFmpeg Plugin Configuration ### Description Configure the FFmpeg plugin to expose the full FFmpeg API, allowing for the conversion of any file type to any other file type. ### Method Configuration ### Endpoint N/A (Configuration within assetpack.config.ts) ### Parameters #### Inputs - **inputs** (string[]) - Required - An array of file extensions to be processed. #### Outputs - **outputs** (object[]) - Required - An array of objects containing the output formats and options for each format. - **formats** (string[]) - Required - An array of file extensions to be output. - **recompress** (boolean) - Required - A boolean value indicating whether the input file should be compressed if the output format is the same as the input format. - **options** (object) - Optional - An object containing the FFmpeg options for the output file. ### Request Example ```ts // assetpack.config.ts import { ffmpeg } from "@assetpack/core/ffmpeg"; export default { ... pipes: [ ffmpeg({ inputs: ['.mp3', '.ogg', '.wav'], outputs: [ { formats: ['.mp3'], recompress: false, options: { audioBitrate: 96, audioChannels: 1, audioFrequency: 48000, }, }, { formats: ['.ogg'], recompress: false, options: { audioBitrate: 32, audioChannels: 1, audioFrequency: 22050, }, }, ], }), ], }; ``` ### Response N/A (This is a configuration example, not an API endpoint response.) ``` -------------------------------- ### Configure AssetPack Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/docs/guide/getting-started/installation.mdx Defines the basic structure for a .assetpack.js configuration file, specifying input directories, output directories, and active pipes. ```javascript export default { entry: './raw-assets', output: './public/assets', pipes: [], }; ``` -------------------------------- ### Configuring TexturePacker Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/docs/guide/pipes/texture-packer.mdx How to integrate and configure the texturePacker plugin within an AssetPack configuration file. ```APIDOC ## TexturePacker Configuration ### Description The `texturePacker` plugin generates texture atlases compatible with PixiJS spritesheets. It supports advanced options for padding, naming conventions, and multi-resolution output. ### Usage Add the `texturePacker` function to the `pipes` array in your AssetPack configuration object. ### Parameters #### texturePacker (Object) - **padding** (number) - Optional - Space between sprites in the atlas. - **nameStyle** (string) - Optional - Strategy for naming files (e.g., "relative"). - **removeFileExtension** (boolean) - Optional - Whether to strip extensions from output filenames. #### resolutionOptions (Object) - **template** (string) - Required - Pattern for resolution naming (e.g., "@%%x"). - **resolutions** (Object) - Required - Map of resolution keys to scale factors. - **fixedResolution** (string) - Optional - The default resolution key to use. - **maximumTextureSize** (number) - Optional - Maximum width/height for generated textures. ### Request Example ```js import { texturePacker } from "@assetpack/core/texture-packer"; export default { pipes: [ texturePacker({ texturePacker: { padding: 2, nameStyle: "relative", removeFileExtension: false, }, resolutionOptions: { template: "@%%x", resolutions: { default: 1, low: 0.5 }, fixedResolution: "default", maximumTextureSize: 4096, }, }) ] }; ``` ``` -------------------------------- ### Configuring Cache Buster Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/docs/guide/pipes/cache-buster.mdx How to implement the cacheBuster plugin in your assetpack.config.ts file. ```APIDOC ## Cache Buster Configuration ### Description The `cacheBuster` plugin generates unique hashes and appends them to file names to bypass browser caching. It should be added to the `pipes` array in your configuration. ### Implementation ```ts import { cacheBuster } from "@assetpack/core/cache-buster"; export default { pipes: [ cacheBuster(), ], }; ``` ``` -------------------------------- ### Resolution Options Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/docs/guide/pipes/texture-packer.mdx Configuration options for generating image resolutions. ```APIDOC ## Resolution Options ### Description Options for generating resolutions. ### Parameters #### Request Body - **resolutionOptions** (object) - Optional - Options for generating resolutions. - **resolutionOptions.template** (string) - Optional - A template for denoting the resolution of the images. Defaults to `@%%x`. ### Request Example ```json { "resolutionOptions": { "template": "@%dx" } } ``` ### Response #### Success Response (200) - **message** (string) - A success message indicating resolutions were generated. #### Response Example ```json { "message": "Resolutions generated successfully." } ``` ``` -------------------------------- ### Image Compression Plugin Source: https://context7.com/pixijs/assetpack/llms.txt Configure the image compression plugin to optimize assets into various formats like JPEG, PNG, WebP, and AVIF. ```javascript import { compress } from "@assetpack/core/image"; export default { entry: './raw-assets', output: './public/assets', pipes: [ compress({ jpg: {}, png: { quality: 90 }, webp: { quality: 80, alphaQuality: 80 }, avif: { quality: 65 }, bc7: false, astc: false, basis: false, etc: false }), ] }; ``` -------------------------------- ### AssetPack CLI Usage Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/docs/guide/getting-started/cli.md This snippet shows how to integrate the AssetPack CLI into your npm scripts for build and watch processes. ```APIDOC ## AssetPack CLI Usage ### Description Integrate the AssetPack CLI into your project's `package.json` scripts to automate asset optimization during build and watch processes. ### Method Command Line Interface (CLI) ### Endpoint N/A (CLI command) ### Parameters #### Command Line Options - `-c` (string) - Optional - Specifies the location of the configuration file. Defaults to `.assetpack.js`. - `-w` (boolean) - Optional - Enables watch mode, monitoring the assets directory for changes and re-running AssetPack automatically. ### Request Example ```json { "scripts": { "prebuild": "assetpack", "build": "your-build-command", "watch:assetpack": "assetpack -w", "watch": "npm run watch:assetpack & your-watch-command" } } ``` ### Response #### Success Response AssetPack processes assets based on the configuration. No direct response body, but optimized assets are generated. #### Response Example N/A (CLI operation) ``` -------------------------------- ### Texture Packer Options Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/docs/guide/pipes/texture-packer.mdx Configuration options for generating texture atlases. ```APIDOC ## Texture Packer Options ### Description Options for generating texture atlases. ### Parameters #### Request Body - **texturePacker** (object) - Optional - Options for generating texture atlases. - **texturePacker.textureFormat** (png|jpg) - Optional - The format of the texture atlas file. Defaults to `png`. - **texturePacker.padding** (number) - Optional - The padding between sprites in the texture atlas. Defaults to `2`. - **texturePacker.fixedSize** (boolean) - Optional - Whether the texture atlas should be a fixed size. Defaults to `false`. - **texturePacker.powerOfTwo** (boolean) - Optional - Whether the texture atlas should be a power of two. Defaults to `false`. - **texturePacker.width** (number) - Optional - The width of the texture atlas. Defaults to `1024`. - **texturePacker.height** (number) - Optional - The height of the texture atlas. Defaults to `1024`. - **texturePacker.allowTrim** (boolean) - Optional - Whether the texture atlas should allow trimming. Defaults to `true`. - **texturePacker.allowRotation** (boolean) - Optional - Whether the texture atlas should allow rotation. Defaults to `true`. - **texturePacker.alphaThreshold** (number) - Optional - The alpha threshold for the texture atlas. Defaults to `0.1`. - **texturePacker.scale** (number) - Optional - The scale of the texture atlas. Defaults to `1`. - **texturePacker.resolution** (number) - Optional - The resolution of the texture atlas. Defaults to `1`. - **texturePacker.nameStyle** (short|relative) - Optional - The name style of the texture atlas. Defaults to `relative`. - **texturePacker.removeFileExtension** (boolean) - Optional - Whether the file extension should be removed. Defaults to `false`. - **texturePacker.autodetectAnimations** (boolean) - Optional - Whether to group sprites with numeric suffixes as animations. Defaults to `true`. - **texturePacker.sharpOptions** (object) - Optional - Options for the sharp library to use when generating the texture atlas. See [sharp resize](https://sharp.pixelplumbing.com/api-resize/#resize). Defaults to `{ }`. ### Request Example ```json { "texturePacker": { "textureFormat": "png", "padding": 4, "fixedSize": true, "width": 2048, "height": 2048, "allowTrim": false, "allowRotation": false, "alphaThreshold": 0.5, "scale": 2, "resolution": 2, "nameStyle": "short", "removeFileExtension": true, "autodetectAnimations": false, "sharpOptions": { "quality": 90 } } } ``` ### Response #### Success Response (200) - **message** (string) - A success message indicating the texture atlas was generated. #### Response Example ```json { "message": "Texture atlas generated successfully." } ``` ``` -------------------------------- ### Configure Manifest Plugin Source: https://context7.com/pixijs/assetpack/llms.txt The pixiManifest plugin generates a JSON manifest file for PixiJS asset loading. It supports folder-based bundling using the {m} tag and exclusion using {mIgnore}. ```javascript import { pixiManifest } from "@assetpack/core/manifest"; export default { entry: './raw-assets', output: './public/assets', pipes: [ pixiManifest({ output: "manifest.json", createShortcuts: true, trimExtensions: false, includeMetaData: true, includeFileSizes: 'gzip', nameStyle: 'short' }), ], }; ``` -------------------------------- ### Programmatic API Integration Source: https://context7.com/pixijs/assetpack/llms.txt Use the AssetPack class in Node.js scripts to control the build process or watch mode programmatically. ```javascript import { AssetPack } from '@assetpack/core'; const assetpack = new AssetPack({ entry: './raw-assets', output: './public/assets', cache: true, strict: true, pipes: [], }); await assetpack.run(); void assetpack.watch(); assetpack.stop(); ``` -------------------------------- ### Spine Atlas Plugins Source: https://context7.com/pixijs/assetpack/llms.txt Process Spine animation atlas files with compression and mipmap generation. Integrates with image processing and manifest generation. ```APIDOC ## Spine Atlas Plugins ### Description Process Spine animation atlas files with compression and mipmap generation. Integrates with image processing and manifest generation. ### Method Configuration within AssetPack ### Endpoint N/A ### Parameters #### Request Body Options - **compressOptions** (object) - Options for image compression (e.g., `{ png: { quality: 90 }, webp: { quality: 80 } }`). - **mipmapOptions** (object) - Options for mipmap generation (e.g., `{ template: "@%%x", resolutions: { default: 1, low: 0.5 } }`). ### Request Example ```javascript import { compress, mipmap } from "@assetpack/core/image"; import { spineAtlasCompress, spineAtlasMipmap, spineAtlasManifestMod } from "@assetpack/core/spine"; import { pixiManifest } from "@assetpack/core/manifest"; const compressOptions = { png: { quality: 90 }, webp: { quality: 80 }, }; const mipmapOptions = { template: "@%%x", resolutions: { default: 1, low: 0.5 }, }; export default { entry: './raw-assets', output: './public/assets', pipes: [ mipmap(mipmapOptions), spineAtlasMipmap(mipmapOptions), compress(compressOptions), spineAtlasCompress(compressOptions), pixiManifest(), spineAtlasManifestMod(), ], }; ``` ### Response #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Integrate AssetPack into npm scripts Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/docs/guide/getting-started/cli.md This JSON configuration demonstrates how to integrate the assetpack command into your package.json scripts. It includes a standard build hook and a watch mode configuration to automate asset optimization. ```json { "scripts": { "prebuild": "assetpack", "build": "your-build-command", "watch:assetpack": "assetpack -w", "watch": "npm run watch:assetpack & your-watch-command" } } ``` -------------------------------- ### Integrate AssetPack with Vite Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/docs/guide/getting-started/vite.md A custom Vite plugin implementation that initializes AssetPack. It automatically detects the public directory, handles watch mode for development, and executes asset processing during production builds. ```typescript import { defineConfig, type Plugin, type ResolvedConfig } from 'vite'; import { AssetPack, type AssetPackConfig } from '@assetpack/core'; function assetpackPlugin(): Plugin { const apConfig: AssetPackConfig = { entry: './raw-assets', pipes: [], }; let mode: ResolvedConfig['command']; let ap: AssetPack | undefined; return { name: 'vite-plugin-assetpack', configResolved(resolvedConfig) { mode = resolvedConfig.command; if (!resolvedConfig.publicDir) return; if (apConfig.output) return; const publicDir = resolvedConfig.publicDir.replace(process.cwd(), ''); apConfig.output = `.${publicDir}/assets/`; }, buildStart: async () => { if (mode === 'serve') { if (ap) return; ap = new AssetPack(apConfig); void ap.watch(); } else { await new AssetPack(apConfig).run(); } }, buildEnd: async () => { if (ap) { await ap.stop(); ap = undefined; } }, }; } export default defineConfig({ plugins: [ assetpackPlugin(), ], }) ``` -------------------------------- ### Audio Conversion Plugin Source: https://context7.com/pixijs/assetpack/llms.txt Converts and compresses audio files to MP3 and OGG formats for broad browser compatibility. This plugin leverages FFmpeg for efficient audio processing. ```javascript import { audio } from "@assetpack/core/ffmpeg"; export default { entry: './raw-assets', output: './public/assets', pipes: [ audio(), ], }; // Input: music.wav // Output: music.mp3, music.ogg ``` -------------------------------- ### Configure Cache Buster with Texture Packer and Spine Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/docs/guide/pipes/cache-buster.mdx Advanced configuration including texturePackerCacheBuster and spineAtlasCacheBuster. These pipes must follow the cacheBuster pipe to ensure internal JSON references are updated with the new hashed filenames. ```typescript import { cacheBuster } from "@assetpack/core/cache-buster"; import { texturePackerCacheBuster } from "@assetpack/core/texture-packer"; import { spineAtlasCacheBuster } from "@assetpack/core/spine"; export default { pipes: [ cacheBuster(), texturePackerCacheBuster(), spineAtlasCacheBuster(), ], }; ``` -------------------------------- ### Integrate AssetPack with Vite Source: https://context7.com/pixijs/assetpack/llms.txt This snippet demonstrates how to create a custom Vite plugin to run AssetPack during development and build processes, ensuring assets are processed automatically. ```typescript import { defineConfig, type Plugin, type ResolvedConfig } from 'vite'; import { AssetPack, type AssetPackConfig } from '@assetpack/core'; import { pixiPipes } from '@assetpack/core/pixi'; function assetpackPlugin(): Plugin { const apConfig: AssetPackConfig = { entry: './raw-assets', pipes: [...pixiPipes({ cacheBust: true, compression: { png: true, webp: true } })], }; let mode: ResolvedConfig['command']; let ap: AssetPack | undefined; return { name: 'vite-plugin-assetpack', configResolved(resolvedConfig) { mode = resolvedConfig.command; if (!resolvedConfig.publicDir) return; if (apConfig.output) return; const publicDir = resolvedConfig.publicDir.replace(process.cwd(), ''); apConfig.output = `.${publicDir}/assets/`; }, buildStart: async () => { if (mode === 'serve') { if (ap) return; ap = new AssetPack(apConfig); void ap.watch(); } else { await new AssetPack(apConfig).run(); } }, buildEnd: async () => { if (ap) { await ap.stop(); ap = undefined; } }, }; } export default defineConfig({ plugins: [assetpackPlugin()] }); ``` -------------------------------- ### POST /texturePackerCompress Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/docs/guide/pipes/texture-packer.mdx Configures the texturePackerCompress plugin to optimize texture atlases using various compression formats. ```APIDOC ## POST /texturePackerCompress ### Description Uses the Sharp library to compress images into formats like JPEG, PNG, WebP, and AVIF, or specialized texture compression standards like ASTC, ETC, and Basis. ### Request Body - **jpg** (object) - Optional - JPEG compression settings. - **png** (object) - Optional - PNG compression settings (e.g., quality). - **webp** (object) - Optional - WebP compression settings. - **avif** (boolean/object) - Optional - AVIF compression settings. - **bc7** (boolean/object) - Optional - BC7 compression settings. - **astc** (boolean/object) - Optional - ASTC compression settings. - **basis** (boolean/object) - Optional - Basis supercompression settings. ### Request Example { "png": { "quality": 90 }, "webp": { "quality": 80, "alphaQuality": 80 } } ### Tags - **nc** (folder) - If present, the atlas will not be compressed. ``` -------------------------------- ### Integrating with Texture Packer and Spine Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/docs/guide/pipes/cache-buster.mdx Using specialized cache buster pipes for texture packers and spine atlas files. ```APIDOC ## Texture Packer and Spine Cache Buster ### Description When using `texturePacker` or `spine` assets, you must use specific cache buster pipes immediately after the main `cacheBuster` pipe to ensure internal references are updated. ### Implementation ```ts import { cacheBuster } from "@assetpack/core/cache-buster"; import { texturePackerCacheBuster } from "@assetpack/core/texture-packer"; import { spineAtlasCacheBuster } from "@assetpack/core/spine"; export default { pipes: [ cacheBuster(), texturePackerCacheBuster(), spineAtlasCacheBuster(), ], }; ``` ``` -------------------------------- ### Define Production AssetPack Pipeline Source: https://context7.com/pixijs/assetpack/llms.txt A complete .assetpack.js configuration file showing the required order of operations. It includes mipmap generation, texture packing, image compression, and manifest creation for PixiJS projects. ```javascript import { compress, mipmap } from "@assetpack/core/image"; import { audio } from "@assetpack/core/ffmpeg"; import { json } from "@assetpack/core/json"; import { webfont, msdfFont } from "@assetpack/core/webfont"; import { texturePacker, texturePackerCompress, texturePackerCacheBuster, texturePackerManifestMod } from "@assetpack/core/texture-packer"; import { spineAtlasCompress, spineAtlasMipmap, spineAtlasCacheBuster, spineAtlasManifestMod } from "@assetpack/core/spine"; import { cacheBuster } from "@assetpack/core/cache-buster"; import { pixiManifest } from "@assetpack/core/manifest"; const resolutionOptions = { template: "@%%x", resolutions: { default: 1, low: 0.5 }, fixedResolution: "default", }; const compressOptions = { png: { quality: 90 }, webp: { quality: 80, alphaQuality: 80 }, avif: false, }; export default { entry: './raw-assets', output: './public/assets', cache: true, cacheLocation: '.assetpack', logLevel: 'info', strict: true, pipes: [ mipmap(resolutionOptions), spineAtlasMipmap(resolutionOptions), texturePacker({ texturePacker: { padding: 2, nameStyle: "short" }, resolutionOptions, }), compress(compressOptions), texturePackerCompress(compressOptions), spineAtlasCompress(compressOptions), audio(), json(), webfont(), msdfFont(), cacheBuster(), texturePackerCacheBuster(), spineAtlasCacheBuster(), pixiManifest({ output: "manifest.json", createShortcuts: true, includeFileSizes: 'gzip', }), texturePackerManifestMod({ includeFileSizes: 'gzip' }), spineAtlasManifestMod(), ], }; ``` -------------------------------- ### Augment Manifest with Spine Atlas Files using AssetPack Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/docs/guide/pipes/manifest.mdx This code snippet demonstrates how to use the `spineAtlasManifestMod` plugin to include Spine atlas files in the AssetPack manifest. It requires importing `pixiManifest` and `spineAtlasManifestMod` and adding `spineAtlasManifestMod()` to the `pipes` array. ```javascript import { pixiManifest } from "@assetpack/core/manifest"; import { spineAtlasManifestMod } from '@assetpack/core/spine' export default { ... pipes: [ ... pixiManifest(), spineAtlasManifestMod(), ] }; ``` -------------------------------- ### Texture Packer Configuration Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/docs/guide/pipes/texture-packer.mdx Defines the configuration options for resolution management and frame naming within the AssetPack texture packer. ```APIDOC ## Configuration Options ### Description Settings to control how images are resized and how data is represented in the manifest. ### Parameters - **resolutionOptions.resolutions** (object) - Optional - An object containing the resolutions that the images will be resized to. Defaults to { default: 1, low: 0.5 }. - **resolutionOptions.fixedResolution** (string) - Optional - A resolution used if the fix tag is applied. Defaults to 'default'. - **resolutionOptions.maximumTextureSize** (number) - Optional - The maximum size a sprite sheet can be before it is split. Defaults to 4096. - **addFrameNames** (boolean) - Optional - Whether to add frame names to the data in the manifest. Defaults to false. ``` -------------------------------- ### Generate Spine Atlas Mipmaps Source: https://github.com/pixijs/assetpack/blob/main/packages/docs/docs/guide/pipes/spine.mdx Configures the spineAtlasMipmap plugin to generate multiple resolutions of Spine atlas images. This is essential for performance optimization across different screen sizes and should be paired with the standard mipmap pipe. ```javascript import { mipmap } from "@assetpack/core/image"; import { spineAtlasMipmap } from "@assetpack/core/spine"; const options = { template: "@%%x", resolutions: { default: 1, low: 0.5 }, fixedResolution: "default", }; export default { pipes: [ mipmap(options), spineAtlasMipmap(options), ] }; ```