Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

How to include files of one clientlib into another clientlibs?

Avatar

Level 1
 
1 Accepted Solution

Avatar

Correct answer by
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

Avatar

Correct answer by
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

Avatar

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.

Avatar

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

Avatar

Employee Advisor

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

Avatar

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

 



Arun Patidar

Avatar

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