Expand my Community achievements bar.

SOLVED

Help needed with Clientlibs and bootstrap

Avatar

Level 2

Hello, I am learning AEM Development. I downloaded the website from the internet and tried to convert it into an AEM project like creating components and adding authoring dialogues to components. The website I downloaded contains files from SCSS from Bootstrap. How can I add this to Clinetlibs? Does Clientlibs support SCSS files? Please give me some clarity. Thanks in advance

 

shamyaswanth_0-1691141429684.png

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @shamyaswanth 

Clientlibs in AEM are used to manage and bundle CSS, JavaScript, and other frontend assets required for your components and pages. By default, AEM supports CSS files, but it does not directly support SCSS files. However, you can use a build process to compile your SCSS files into CSS and then include them in your AEM project.

Here's a general approach to handling SCSS files and Clientlibs in AEM:

  1. Set up a build process: You'll need a build process to compile your SCSS files into CSS files. Popular build tools like Gulp, Grunt, or Webpack can be used for this purpose. You'll need to install the required packages and configure the build process to watch and compile SCSS files into CSS.

  2. Organize your SCSS files: Organize your SCSS files into manageable directories and make sure to have an entry point for your SCSS (e.g., main.scss). This is the file you'll include in your Clientlibs.

  3. Create an AEM Clientlib: In your AEM project, create a Clientlib that will include the compiled CSS. You can do this through the AEM Web Console or by using CRXDE Lite.

  4. Include the compiled CSS in the Clientlib: After compiling your SCSS files into CSS, include the generated CSS file in your AEM Clientlib.

  5. Include the Clientlib in your components: Once your Clientlib is created and contains the CSS, include the Clientlib in your AEM components or templates. This will make sure that the CSS is loaded when the component is rendered on a page.

  6. Apply the Clientlib to pages: Ensure that the pages using your components include the clientlib. This can be done either by adding the Clientlib to the page template or by including it directly on individual pages.

Also, some AEM projects use third-party tools like AEM Clientlib Compiler or AEM Frontend Maven Plugin, which simplify the handling of frontend assets, including SCSS files. These tools can be very useful for automating the build process and integration of front-end assets in AEM.

View solution in original post

3 Replies

Avatar

Correct answer by
Community Advisor

Hi @shamyaswanth 

Clientlibs in AEM are used to manage and bundle CSS, JavaScript, and other frontend assets required for your components and pages. By default, AEM supports CSS files, but it does not directly support SCSS files. However, you can use a build process to compile your SCSS files into CSS and then include them in your AEM project.

Here's a general approach to handling SCSS files and Clientlibs in AEM:

  1. Set up a build process: You'll need a build process to compile your SCSS files into CSS files. Popular build tools like Gulp, Grunt, or Webpack can be used for this purpose. You'll need to install the required packages and configure the build process to watch and compile SCSS files into CSS.

  2. Organize your SCSS files: Organize your SCSS files into manageable directories and make sure to have an entry point for your SCSS (e.g., main.scss). This is the file you'll include in your Clientlibs.

  3. Create an AEM Clientlib: In your AEM project, create a Clientlib that will include the compiled CSS. You can do this through the AEM Web Console or by using CRXDE Lite.

  4. Include the compiled CSS in the Clientlib: After compiling your SCSS files into CSS, include the generated CSS file in your AEM Clientlib.

  5. Include the Clientlib in your components: Once your Clientlib is created and contains the CSS, include the Clientlib in your AEM components or templates. This will make sure that the CSS is loaded when the component is rendered on a page.

  6. Apply the Clientlib to pages: Ensure that the pages using your components include the clientlib. This can be done either by adding the Clientlib to the page template or by including it directly on individual pages.

Also, some AEM projects use third-party tools like AEM Clientlib Compiler or AEM Frontend Maven Plugin, which simplify the handling of frontend assets, including SCSS files. These tools can be very useful for automating the build process and integration of front-end assets in AEM.

Avatar

Community Advisor

Hi @shamyaswanth 

 

The approach for adding SCSS files to Clientlibs can vary based on the version of AEM you are using.

  1. If you are using AEM on-premise, you need to follow a specific file structure to include SCSS files in your Clientlibs. Usually, you would place your SCSS files in the src/main/content/jcr_root/apps/your_project/clientlibs directory. You'll need to create a Clientlib node (cq:ClientLibraryFolder) in the CRXDE Lite or via the AEM Web Console to organize your CSS and SCSS files properly. Then, you can configure the Clientlib to compile and minify the SCSS files into CSS using the clientlib settings.

  2. If you are using AEM as a managed service, the file structure might differ slightly, and you'll need to follow the AEM Cloud Service's guidelines. You might have to place your SCSS files in the appropriate location within your project's codebase.

  3. If you are using AEM as a cloud service, you may not need to use Clientlibs at all. The AEM as a Cloud Service follows a different approach using the Adobe Asset Compute Service and the Style System to handle SCSS processing and styling.

Regardless of the version you are using, it's essential to check the official AEM documentation and guidelines specific to your version and environment. The documentation will provide detailed instructions on how to manage SCSS files and Clientlibs properly.

Regarding 3rd point

  1. Create an AEM Clientlib: In your AEM project, create a Clientlib that will include the compiled CSS. You can do this through the AEM Web Console or by using CRXDE Lite. --> How can we create Clientlib with AEM Web Console, could you help me with steps?