Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Web component inside Liferay DXP
Does someone have experience with web components inside Liferay DXP (how can be embedded)?
We fiddled a bit with them. I wrote a blog post a while ago and the code there used them.
https://liferay.dev/blogs/-/blogs/developing-javascript-frontends-with-webpack
https://github.com/dccs-liferay/webpack-example/blob/master/modules/dccs-frontend-demo/webpack/js/app.js
But in the end, we went with the alternative approach in that code example, it proved simpler to handle.
Hi Christoph, i have tried this solution with dccs-frontend-demo. As
result of build i have dccs-frontend-demo.jar in bundles/osgi/modules
folder. I am using liferay dxp localy on my machine (version 7.3), and
i have copied this jar into this
folder C:\liferay-dxp-tomcat-7.3.10-ga1-20200930160533946\liferay-dxp-7.3.10-ga1\osgi\modules,
but when i run Liferay dxp application i cannot find this app in
search. I don't know what to do to make this jar app to be visible in
this widgets search ?
That's because it isn't an app, it just adds the infrastructure js code. If it works correctly, it just registers a loader in the theme. When you check the source code of the page, you should find something like this in the footer:
<link href='<PATH>/app.css?<HASH>' rel='stylesheet'/>
<script src='<PATH>/runtime.js?<HASH>'></script>
<script src='<PATH>/vendor.js?<HASH>'></script>
<script src='<PATH>/app.js?<HASH>'></script>
When you put a webcomponent now on the page, the code is triggered. You can do this using webcontent, a fragment, inside of a portlet, ...
To test it, add a webcontent or fragment to the page with these tags:
<hello-world/>
<app-today />
<app-shuffle />
The tags should be picked up by the module and replaced.
Note: It is quite possible that the module isn't deployed correctly at all, you probably need to fix the kernel version in build.gradle.