pixi.js is about 226kb minified + gzipped (as of v7.3.2).
If you’re only using a few features this may be a lot more than you need.
With a modern bundler it is possible to create your own pixi.js file with only the features you need. This
guide will show you how to do it using Vite as that is the most common bundler used with Svelte.
Creating a custom pixi.js file
The pixi.js package is just a collection of various @pixi/* packages. If we look at their package.json,
we can see which ones we might want to install for ourselves.
I’ve picked out a few below. You can add/remove as necessary, but note that if any SveltePixi component
relies on the package you’ll get an error. (For example, if you remove @pixi/sprite you’ll get an error
when using <Sprite />.)
Copy & paste the following into a file called pixi.js:
Make sure to install them too
Aliasing
In order for SveltePixi to make use of this custom file we’ll need to create an alias.
Update your vite.config.js file to include the following: