vaadin / portlet

Portlet support for Vaadin Flow
https://vaadin.com
Other
2 stars 3 forks source link

Vaadin 23.2 Vite not working with Liferay portlets #240

Open krissvaa opened 2 years ago

krissvaa commented 2 years ago

Vaadin 23.2 using default settings (using Vite) builds but when portlets are deployed on Liferay fails with missing stats.json.

mshabarov commented 2 years ago

For Vite build tool we can generate a basic stats.json in Flow, so Portlet wouldn't throw an error.

krissvaa commented 1 year ago

Seems there is another issue, that web-component.html is missing when built with VITE (or just in wrong path, could be problem with not searching for it under/o/static-vaadin-portlet)

For now there is a workaround - but it is not a pretty one as portlets will include static files as well: For example inside https://github.com/vaadin/addressbook-portlet/blob/v23/addressbook-form/pom.xml Using this configuration

        <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
            </plugin>
            <plugin>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-maven-plugin</artifactId>
                <version>${vaadin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-frontend</goal>
                            <goal>build-frontend</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.2.3</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>war</goal>
                        </goals>
                        <configuration>
                            <primaryArtifact>true</primaryArtifact>
                            <packagingExcludes>WEB-INF/classes/META-INF/VAADIN/build/**,VAADIN/</packagingExcludes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
mcollovati commented 1 year ago

The problem with web-component.html is that at runtime it is read from class path at the position META-INF/VAADIN/webapp/we-component.html, and this file is generated by vaadin-maven-plugin. In a multimodule project with a static bundle portlet, the file is present only on this one, and is not accessible by other modules as classpath resource. We should investigate if a custom ResourceProvider implementation may work in this situation

mcollovati commented 1 year ago

For multimodule projects, there's a workaround, but it requires a bit of configuration. Basically, the idea is to add a companion module (as an additional pom file in the same folder) for every portlet that builds the classes jar used by the static bundle module. The static bundle module generates the war and an addition JAR artifact that contains only META-INF/VAADIN/webapp/ files. This jar is then added as a dependency to the portlet war POM.

An example can be found in the addressbook-portlet issues/portlet-243 branch