I have an addon Jar to allow embedding a specific font. It has the following content:
- /META-INF/resources/frontend/font-roboto.css
- /META-INF/resources/fonts/roboto-*.woff2
The URL paths used in the CSS file are currently of the form: fonts/roboto-xyz.woff2
However, this font path doesn’t work as soon as vaadin.url-mapping
is set for the application. I then need to prefix the path with ../
, because the base path of the application changes while the actual font URL stays the same. Having to adapt static files to match dynamic configuration isn’t ideal.
I suppose I could use an absolute path like /fonts/roboto-xyz.woff2
instead, but then it will break when setting server.servlet.context-path
. For a new (Spring Boot) application there’s admittedly no good reason to do this, but it’s not necessarily easy to change for applications that already do.
Is there are clever, uniform way to solve this, or do I need to provide two CSS files?