Skip to main content

AssetPack 1.0.0 Release!

ยท 5 min read
Zyie

Today we are very excited to announce AssetPack 1.0, an asset management and optimization tool for web developers.

In the world of web development, managing and optimizing assets often demands significant manual effort. Developers need to ensure that their images are compressed, their audio files are optimized, their fonts are loaded efficiently, and more. This process can be time-consuming and error-prone, especially when working on large projects with many assets. To address this challenge, AssetPack provides a configurable asset pipeline that automates many of these tasks, making it easier for developers to manage and deploy assets in their projects.

What is AssetPack?โ€‹

AssetPack is a tool designed to streamline the management, optimization, and deployment of assets in web projects. It is framework-agnostic and can be used with any framework you like, such as PixiJS, Three.js, Phaser, and others. AssetPack employs a plugin-based system, allowing you to create your own plugins to customize asset processing according to your needs.

AssetPack screenshot

AssetPack comes out of the box with the following plugins:

  • Cache Busting: Automatically appends a unique hash to asset URLs to ensure that clients always load the latest version of the asset.
  • Compression: Compresses images using sharp, allowing for the creation of webp/avif images and compressing png/jpg to reduce file sizes.
  • TexturePacker: Automatically generates spritesheets from images.
  • Mipmap: Generates mipmaps for textures to improve rendering performance e.g. 2x, 1x, 0.5x, etc.
  • Spine: Optimizes Spine animations by creating mipmaps for .atlas files.
  • Audio/FFmpeg: Converts audio files to the desired format and bitrate using FFmpeg.
  • JSON: Minifies JSON files to reduce their size.
  • Webfont: Converts all fonts files to WOFF2 format, and plugins for SDF and MSDF font generation
  • Manifest: Generates a manifest file containing all asset URLs for easy loading. This can be used with PixiJS's Assets loader

The above plugins are just a few examples of what AssetPack can do. You can create your own plugins to extend AssetPack's functionality further.

Key Features of AssetPackโ€‹

Caching & CIโ€‹

AssetPack intelligently caches assets, transforming each asset only once. This reduces redundant processing and speeds up build times, ensuring that you always have the latest version of your assets without unnecessary overhead.

This is perfect for Continuous Integration (CI) environments, AssetPack allows you to commit raw assets to your repository and transform them as part of your build process. This ensures that your assets are always optimized and up-to-date with minimal manual intervention. See the Github Action example here for more information.

Performanceโ€‹

Designed to handle large quantities of assets, AssetPack utilizes the fastest tools available. This ensures that your asset pipeline can keep up with the demands of modern web development, delivering optimized assets quickly and efficiently.

Watch Modeโ€‹

With the Watch mode, AssetPack monitors your assets in real-time, updating them as you add or remove files. This live update feature streamlines development, allowing you to see changes immediately without having to manually trigger asset processing. Combined with the caching system, Watch mode ensures that only the necessary assets are transformed, keeping build times to a minimum.

Tag Systemโ€‹

AssetPack's tag-powered system makes asset management intuitive and flexible. By simply adding tags to folders or files (e.g., {tps} to create a sprite sheet), you can easily apply specific processing rules. This feature simplifies complex asset workflows and enhances customization.

AssetPack screenshot

How to use AssetPackโ€‹

Installationโ€‹

To install AssetPack, you need to install the @assetpack/core package.

npm install --save-dev @assetpack/core
COMPATIBILITY NOTE

AssetPack requires Node.js version 20+, please upgrade if your package manager warns about it.

Setupโ€‹

To set up AssetPack, you need to create a configuration file that defines what assets you want to optimise and how you want to optimise them.

First create a .assetpack.js file in the root of your project. This file should export an object with the following properties:

// .assetpack.js
import { pixiPipes } from '@assetpack/core';

export default {
entry: './raw-assets',
output: './public/assets',
pipes: [
/* If you are using AssetPack with PixiJS, you can use the `pixiPipes` function
* to add a pre-configured set of plugins, with an opinionated
* set of defaults for PixiJS.
*/
...pixiPipes()
],
};

To see the full list of configuration options, see the API Reference page.

Then to run AssetPack, you can use the CLI, run programmatically, or use a build tool like Vite.

AssetPack has a number of built-in plugins for you to use, to see the full list of plugins, see the Plugins page.

Open Source Gamesโ€‹

AssetPack is already in use in our open source games repo. Check out the games leveraging AssetPack for asset management. These examples showcase the power and flexibility of AssetPack in real-world scenarios.

Conclusionโ€‹

AssetPack is a powerful tool that can help you manage and optimize assets in your web projects. By automating many of the tasks involved in asset management, AssetPack can save you time and effort, allowing you to focus on building great web experiences. We hope you find AssetPack useful in your projects, and we look forward to seeing what you create with it!

We are committed to continuously improving AssetPack, and your feedback is invaluable to us. If you encounter any issues or have suggestions for new features, please reach out on our discord or open an issue on our GitHub repository.

๐ŸŒ Stay Connectedโ€‹

Follow Zyie and PixiJS on social media for the latest updates. Join our vibrant community on Discord for real-time discussions and support.