Flow: Vaadin for TypeScript: static files location handling for @pwa

Created on 27 Aug 2020  路  6Comments  路  Source: vaadin/flow

The offlineResources property in @pwa annotation should work the same as in V17. See this documentation

Low Major bug fusion

All 6 comments

Need to clarify which files this actually means (or is this issue needed separately at all).

This is based on the commit message saying "Static files for @鈥媝wa are generated in the standard static files folder so no special serving is needed". I think it might only mean the icons (which were served in a special way before?), but maybe also webmanifest, service worker and webpack config.

Close as this is implemented in https://github.com/vaadin/flow/pull/8940

The way how the offlineResources property of the @PWA annotation is handled in #8940 is incompatibly different from how it's handled in V17:

With #8940 the files listed in the offlineResources property are resolved at the build time by webpack, relative to the src/main/webapp folder in the project file system. With V17 these files are resolved at the run time by the service worker, through the running web app by URL.

Since the V17 approach relies on the running web app's URL-to-file resolution logic, it means that the actual location of these files on the file system may vary a lot.

With the default setup Spring Boot apps serve static files from the /static, /public, /resources, and /META-INF/resources locations in the class path (in the project itself or in any .jar it loads), as well as from the src/main/webapp folder in the project (which is the .war-specific convention for static files for Java web apps). These defaults can be changed by configuration. See more details e.g. in https://vaadin.com/docs/v17/flow/importing-dependencies/tutorial-ways-of-importing.html or https://www.baeldung.com/spring-mvc-static-resources

Picking only the src/main/webapp folder as the supported location of files referenced in the offlineResources property is an incompatible breaking change from V17. It excludes any files that come from .jars as well as any files that are located in e.g. src/main/resources/META-INF/resources.

Here are the missing bits before this task can be completed:

  • either change the V18 approach so that the files referenced in the offlineResources property are resolved at the run time through the web app by URL rather than at the build time by a file name
  • ~or keep the resolution at the build-time and update the https://vaadin.com/docs/v17/flow/pwa/tutorial-pwa-service-worker.html#defining-custom-cache-resources documentation page to make it explicit that the files should be placed in the src/main/webapp folder~

UPD: Spring Boot documentation explicitly discourages usage of the src/main/webapp folder:

Do not use the src/main/webapp directory if your application is packaged as a jar. Although this directory is a common standard, it works only with war packaging, and it is silently ignored by most build tools if you generate a jar.

Vaadin official documentation should not conflict with the Spring Boot recommendations unless there is a good reason. I do not see a good reason here.

@vlukashov Thanks for the clarification. Now I understand what this is about. Should probably be marked as a bug instead of enhancement?

UPD: Spring Boot documentation explicitly discourages usage of the src/main/webapp folder:

Do not use the src/main/webapp directory if your application is packaged as a jar. Although this directory is a common standard, it works only with war packaging, and it is silently ignored by most build tools if you generate a jar.

Vaadin official documentation should not conflict with the Spring Boot recommendations unless there is a good reason. I do not see a good reason here.

Was this page helpful?
0 / 5 - 0 ratings