hzjqn Posted October 24, 2022 Share Posted October 24, 2022 Hello everyone, I'm suggesting using pixi (v5) for a component on a really bloated site, and its bringing too much weight to the final bundle. We don't need everything the library offers, so I was wondering if we can import what we need and maybe minimize the impact on the final bundle weight. Has anyone encountered a similar issue? How did you manage it? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted October 25, 2022 Share Posted October 25, 2022 Make your own bundle, you can strip like half of pixi size. Usually. But as soon as you add something like Spine, its gets 4x by weight :))) https://pixijs.io/customize/ might help you hzjqn 1 Quote Link to comment Share on other sites More sharing options...
hzjqn Posted October 25, 2022 Author Share Posted October 25, 2022 Thank you! It did help! Does this work if I use the npm package aswell? By importing only the things I use {Sprite} from @pixi/Sprite instead of importing * as PIXI from @pixi/core as a whole and doing something like PIXI.Sprite? And also, as I need the PIXI instance for the gsap.registerPixi plugin, wouldn't I need to import the whole PIXI object? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted October 26, 2022 Share Posted October 26, 2022 Look, the whole trick is to run the certain code before app starts For that purpose, you have to create your own bundle file, that imports all stuff and exports PIXI. Make sure it loads before your app starts rendering, this is necessary condition that webpack cannot guarantee. That is why we do things like that - we do not know all the ways users can create abomination that runs before our code runs. 1. Default way is to use "import {..} from PIXI" everywhere - yes, that's enough. 2. Alternatively, include that bundle in APP in that case you can use any imports directly from our @pixi/Sprite and other libs. hzjqn 1 Quote Link to comment Share on other sites More sharing options...
hzjqn Posted October 26, 2022 Author Share Posted October 26, 2022 Makes sense. I'll check whats best for the project I am working on. Thanks a lot! Hope you are doing well Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.