How to include files of one clientlib into another clientlibs? | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Nupur_Jain

Hi @saurabh_intel 

 

What I am able to understand is that you want to include one clientlib into another. For this, you will have to use "embed"  feature of clientlibs i.e used to embed code from other libraries. If clinetlibs F embeds clinetlibs G and H, the resulting js and css files included in the html will be a concetration of js and css from clinetlibs G and H.

 

 To embed clientlibs, mention clientlibs name in the "embed" property on your site cq:ClinetlibraryFolder like this:

[cq:ClientLibraryFolder] > sling:Folder
  - dependencies (string) multiple
  - categories (string) multiple
  - embed (string) multiple
  - channels (string) multiple

Also, refer https://docs.adobe.com/content/help/en/experience-manager-65/developing/introduction/clientlibs.html for more details.

 

If this is not not what you want, please elaborate your question in details.

 

Hope it helps!

Thanks

Nupur

5 replies

Nupur_Jain
Adobe Employee
Nupur_JainAdobe EmployeeAccepted solution
Adobe Employee
September 4, 2020

Hi @saurabh_intel 

 

What I am able to understand is that you want to include one clientlib into another. For this, you will have to use "embed"  feature of clientlibs i.e used to embed code from other libraries. If clinetlibs F embeds clinetlibs G and H, the resulting js and css files included in the html will be a concetration of js and css from clinetlibs G and H.

 

 To embed clientlibs, mention clientlibs name in the "embed" property on your site cq:ClinetlibraryFolder like this:

[cq:ClientLibraryFolder] > sling:Folder
  - dependencies (string) multiple
  - categories (string) multiple
  - embed (string) multiple
  - channels (string) multiple

Also, refer https://docs.adobe.com/content/help/en/experience-manager-65/developing/introduction/clientlibs.html for more details.

 

If this is not not what you want, please elaborate your question in details.

 

Hope it helps!

Thanks

Nupur

September 4, 2020

thanks for answer Nupur, I want to ask 

 

Let say there is clientlib A  in which 5 files are there,

 

I wan to use 3 files from clientlib A in clientlib B.

 

How can we do this.

ArpitVarshney
Community Advisor
Community Advisor
September 4, 2020

Hi @saurabh_intel 

Why don't you create a common client-lib which include common files and create two clientlibs embedding the common clientlibs?

 

Regards,

Arpit Varshney

Surabhi_Katiyar
Adobe Employee
Adobe Employee
September 5, 2020

In order to include the code of one client library file into another you have two options available:

 

1. Linking the two files: You can link the dependent file to the parent file and for this, you can use the concept of Linking of Dependencies which has been explained in details in the below link:

 

https://docs.adobe.com/content/help/en/experience-manager-65/developing/introduction/clientlibs.html#linking-to-dependencies

 

2. Embed the two files: Or you can embed the code of the dependent file in the parent file and for this please check the below link:

 

https://docs.adobe.com/content/help/en/experience-manager-65/developing/introduction/clientlibs.html#embedding-code-from-other-libraries

arunpatidar
Community Advisor
Community Advisor
September 5, 2020

I would also recommend to use embed feature of clientlibs but technically it is possible to use file of one clientlibs into another.

Example - 

clientlib-site-A is using a.less from clientlib-site-B

 

 

 

Arun Patidar
Nikhil-Kumar
Community Advisor
Community Advisor
September 6, 2020

@saurabh_intel 

You can use the embed prop to achieve this requirement. 
https://docs.adobe.com/content/help/en/experience-manager-65/developing/introduction/clientlibs.html

Also as you mentioned you want to use some files from one client into another then in that I would suggest to have the common js/css in master clientlib and embed it in clientlib 1 and clientlib 2.

Doing so will fulfill your requirement.

Thanks,
Nikhil