rexrainbow / phaser3-rex-notes

Notes of phaser3 engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does UI component support on-demand introduction?

cy920820 opened this issue · comments

commented

Do you mean that importing class directly, without using factory (scene.rexUI.add.xxx)?
Yes, it has. For example, import Label class. (More classes...)

Will unused components be packaged into the project, eventually increasing the size of the application?

commented

It depends on bundle tool like rollup, or webpack. Usually they can include imported module/class only.
BTW, factory (scene.rexUI.add.xxx) solution will include all of them in rexui plugin.

I just want to package the UI components used to prevent the project volume from increasing

commented

You can import class directly like

import { Label } from 'phaser3-rex-plugins/templates/ui/ui-components.js';

thanks bro

You can import class directly like

import { Label } from 'phaser3-rex-plugins/templates/ui/ui-components.js';

I am using the vite build tool, so I think it should be dynamic import

const { Label } = await import('phaser3-rex-plugins/templates/ui/ui-components.js');

Is that so?

commented

I did not use await import(...) in my test environment, sorry can't help you.