I have just checked the GitHub actions logs, the upgrade from webpack 4 to 5 did not really speed up the UI build.
I honestly haven’t checked that closer; but after the first local UI build the following ones should be a bit faster since all dependencies are already installed and shouldn’t have been removed unless you use the clean command with mvn.
In order to speed up the build you probably need to have a look on Vite. It is being said to be faster during development due to different strategy used for code swapping. Disclaimer - I am not a web developer hence I am not sure if it gives any significant boost with web-bundling itself.
Yarn could speed up the depedency installation, but should not improve build times.
As Lukasz said, Vite could improve the build times, it is said to be reallly fast, but since normally only CI does real UI builds and the webpack dev server is also really fast, I don’t see a benefit in using Vite that would convince me in spending my time in changing the build system.