Issue
- You need to deploy a custom client extension to specific instances. What are the next steps?
Environment
- DXP 7.4 Quarterly Releases.
- On-Premise, Local environment and PaaS
Resolution
- A custom element client extension will be used for this example. Please check Liferay source code for more client extension examples.
Option 1: One Client Extension for each Instance
- Declaring more than one client extension with the same code could be useful in certain situations, but could lead to deployment errors if the instance (defined by webId) does not exists.
- You will need to modify client-extension.yaml accordingly:
sample-custom-element-instance1:
dxp.lxc.liferay.com.virtualInstanceId: <instance1-webId>
...
sample-custom-element-instance2:
dxp.lxc.liferay.com.virtualInstanceId: <instance2-webId>
...
- A single ZIP file will be deployed into the defined instances as individual client extensions.
Option 2: Deploy Client Extension by Configuration
- Another for deploying Client Extension configuration can be followed with this blog entry.
- This approach is usually recommended for remote applications with specific URLs.
baseURL="<base-url>"
dxp.lxc.liferay.com.virtualInstanceId="<instance-webId>"
name="CX Example"
type="customElement"
typeSettings=[ \
"friendlyURLMapping=example", \
"instanceable=false", \
"urls=/custom-path/index.js",\
"useESM=false",\
"htmlElementName=example",\
"cssURLs=",\
"portletCategoryName=category.client-extensions"\
]
- If
baseURL=""is set, resources will be loaded from the current domain. - It is important to be aware that browser cached files may not update automatically with this approach.
Option 3: Compile/Deploy directly for any specific instance
- This option is only available from liferay workspace 11.0.0+.
- An environment variable would include the specific instance webId at build time:
blade gw deploy -Pliferay.virtual.instance.id=<instance-webId>
- Therefore, each instance will have its own compiled ZIP file.
Additional Information