
Security News
PEP 810 Proposes Explicit Lazy Imports for Python 3.15
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
vite-spritesheet-plugin
Advanced tools
Generate large spritesheets to save on network. Supports SVG, PNG, JPEG.
Output files are rasterized as PNG or JPEG.
Include this in your Vite plugin configuration.
Configuration options are as follows:
interface PluginOptions {
/**
* List of patterns to search for assets
*/
patterns: {
/**
* Root directory to search for assets.
*/
rootDir: string
/**
* Glob expression to match assets.
* @default *.{png,gif,jpg,bmp,tiff,svg}
*/
glob?: string
}[]
options?: Partial<{
/**
* Format of the output image
* @default "png"
*/
outputFormat: "png" | "jpeg"
/**
* Output directory
* @default "atlases"
*/
outDir: string
/**
* Added pixels between sprites (can prevent pixels leaking to adjacent sprite)
* @default 1
*/
margin: number
/**
* Remove file extensions from the atlas frames
* @default false
*/
removeExtensions: boolean
/**
* The Maximum width and height a generated image can be
* Once a spritesheet exceeds this size a new one will be created
* @default 4096
*/
maximumSize: number
/**
* maxrects-packer options
* See https://soimy.github.io/maxrects-packer/
* Currently does not support `allowRotation` option
*/
packerOptions: Omit<IOption, "allowRotation">
}>
}
Then to import the spritesheets, use
import { atlases } from "virtual:spritesheets-jsons";
import { Texture, Spritesheet, Sprite } from "pixi.js";
import { atlases } from "virtual:spritesheets-jsons";
const textures: Record<string, Texture> = {};
for (const atlas of atlases) {
const texture = await Texture.fromURL(atlas.meta.image);
const spriteSheet = new Spritesheet(texture, atlas);
await spriteSheet.parse();
for (const frame in spriteSheet.textures) {
textures[frame] = spriteSheet.textures[frame];
}
}
const sprite = new Sprite(textures["file_name"]);
FAQs
A spritesheet plugin for Vite.
We found that vite-spritesheet-plugin demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
Security News
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.