Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

How to include files of one clientlib into another clientlibs?

saurabh_intel
Level 1
Level 1
 
1 Accepted Solution
Nupur_Jain
Correct answer by
Community Advisor
Community Advisor

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

View solution in original post

6 Replies
Nupur_Jain
Correct answer by
Community Advisor
Community Advisor

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

saurabh_intel
Level 1
Level 1

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

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

surabhikatiyar
Employee
Employee

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...

 

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...

Arun_Patidar
Community Advisor
Community Advisor

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_0-1599330638392.png

 

Nikhil-Kumar
Community Advisor
Community Advisor

@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