How do I need to handle frontend
resources that are from another project?
I have problems with upgrading a V13 Project (“PROJ_A”) of mine. My Issue seems to come from the fact that this project has a dependency to another project (“PROJ_B”) of mine, where I define my own Implementations of Vaadin Components and static Helper Classes, to be reused in other vaadin projects.
PROJ_B has a Class CloseButton
which extends Button
, and is annotated with @CssImport("./styles/components/closeButton.css")
. This css file ist stored in [project-root] /frontend/styles/components/closeButton.css
.
When I go and install and run the PROJ_B I see in the file [project-root] /target/frontend/generated-flow-imports.js
it added two lines about the closeButton.css:
import $css_0 from 'Frontend/styles/components/closeButton.css';
addCssBlock(`<custom-style><style>${$css_0}</style></custom-style>`);
Looking at a TestView that I implemented in PROJ_B, it works and the CloseButton can be displayed.
But now I would like to use that CloseButton in another Project, PROJ_A. I have followed the Migration Tutorial for this project and everything seems to work, if I don’t use the CloseButton anywhere, so the migration part seems to be finished. But when I now include a CloseButton in a View, running the PROJ_A will fail with an IllegalStateException, saying that it could not find the css file styles/components/closeButton.css
.
java.lang.IllegalStateException: Failed to update the Flow imports file 'C:\pathToProject\PROJ_A\target\frontend\generated-flow-imports.js'
at ....
Caused by: java.lang.IllegalStateException:
[INFO]
[INFO]
Failed to find the following css files in the `node_modules` or `/frontend` tree:
[INFO]
- styles/components/closeButton.css
[INFO]
Check that they exist or are installed.
As soon as I manually copy that css file from PROJ_B to PROJ_A, it works. But I can’t believe that this is the intended way to go. I would need to include any frontend files of all third-party add-ons etc manually in my project? I assumed it should work without doing that. Can anybody clear this up for me? Thank you