flow icon indicating copy to clipboard operation
flow copied to clipboard

Custom PWA icons replaced by default production bundle images

Open mcollovati opened this issue 7 months ago • 5 comments

Description of the bug

Given a Vaadin application with PWA enabled and a custom icon in the project in default location src/main/resources/META-INF/resources/icons/icon.png, when the application is built for production the PWA icons are generated correctly by TaskGeneratePWAIcons, but then replaced by the images present in the default production bundle when TaskPrepareProdBundle is executed.

To be noted that if @PWA.iconPath is set to a value different from icons/icon.png the icons are rendered correctly, but the production artifact contains both the custom and the default icons.

Expected behavior

If there's a custom PWA icon in the project, the generated PWA icons should not be overwritten by the contents of the bundle.

Minimal reproducible example

  • Create a simple Vaadin application and annotate it with @PWA
  • Copy a custom image in src/main/resources/META-INF/resources/icons/icon.png
  • Build for production with mvn package -Pproduction
  • Run the application from the fat-JAR (java -jar target/whatever-x.y.z.jar) and open the application in a browser
  • Verify in the dev tools that the PWA icons are the default ones and not the custom ones.

A simpler way to verify the bug is to uncompress the fat-JAT and check the files in /META-INF/VAADIN/webapp/pwa-icons/icons/

Versions

  • Vaadin / Flow version: 24.7
  • Java version: 21

mcollovati avatar May 09 '25 12:05 mcollovati

👍 Something to consider when opening this part: a bit more logging about the icon generation might have helped me to get over my recentt "WTF moment" faster.

mstahv avatar May 09 '25 12:05 mstahv

What kind of log messages would have helped you?

mcollovati avatar May 09 '25 13:05 mcollovati

Workaround is to force the re-build of production bundle (with vaadin.force.production.build) or to change the location of icon.png.

mshabarov avatar May 13 '25 10:05 mshabarov

What kind of log messages would have helped you?

What exact image file is used when generating the scaled versions. That would have probable helped me to figure out that it is not using mine, but the blue default icon. Maybe extra warning if the icons are generated from that default image 🤔

mstahv avatar May 14 '25 14:05 mstahv

What exact image file is used when generating the scaled versions. That would have probable helped me to figure out that it is not using mine, but the blue default icon. Maybe extra warning if the icons are generated from that default image

Currently, the task prints Generating PWA icons from '<@PWA.iconPath>', but at DEBUG level. In your case, however, the icon used for generation was the one you provided. The problem is that it was overwritten after generation by the default bundle contents, so a log message would not have helped.

mcollovati avatar May 14 '25 14:05 mcollovati