I would like my V14 UI application to depend on / use a JavaScript file from within a Maven-included component. Can anyone tell me how to achieve that…?
I am writing an adapter for Mapbox [1]
, where this would help me to avoid having to duplicate the mapbox.js file that contains the JS part of the adapter in the UI component where it is used.
\u0000I’ve tried various combinations, but have not been successful yet. Can someone give me a hint how to add a @JsModule and @CssImport to my MapboxMap class that extends Div…? And where to put the JS and CSS source files…? \uD83D\uDE4F\uD83C\uDFFB
I prefer to split my add-on into 2 modules, one for the jar file and for my test project but that shouldn’t matter:
Here another example here (split into 2 maven modules): https://github.com/jcgueriaud1/sortable-layout
If you are using cdn, or external js it’s much easier. It can be tricky if you want to use webpack (it may depend on mapbox js library). You can start with cdn then try to switch to webpack and npmpackage later.
Thank you Peter, Jean-Christophe, I have been able to load the includes now. Turned out I was looking for the problem in the wrong location - in the class, rather than in the pom.xml, which contained a misconfiguration.
For me, adding the includes via tags [1]
does not work, but it worked via the page object [2]
.
I’ve updated GitHub. To be continued.
[1]
@JavaScript("./mapbox.js"); @CssImport("./mapbox.css") // at the top of the class definition