Saturday, December 28, 2019

Lightning Web Component Bundle

LWC bundle contains an HTML file, a JavaScript file, and a metadata configuration file as shown in the below image and these files are created once we create a Lightning web component.


Lightning Web Component Bundle


HTML FILE:

The HTML file is enclosed within the <template> tags.  It contains the component HTML.


LWC bundle


JAVASCRIPT FILE:

A sample javascript file is shown in the below image.

LWC bundle


Metadata configuration file:

A sample metadata configuration file is shown in the below image.


Lightning Web Component Bundle

A sample metadata configuration file is shown below. The configuration file defines the metadata values for the components including the design configuration for the lightning app builder and community builder.

<?xml version="1.0" encoding="UTF-8"?>

<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">

    <apiVersion>50.0</apiVersion>

  <isExposed>true</isExposed>

    <targets>

        <target>lightning__AppPage</target>
        <target>lightning__RecordPage</target> 
        <target>lightning__HomePage</target> 
        <target>lightningCommunity__Default</target> 
        <target>lightningCommunity__Page</target> 


    </targets>

</LightningComponentBundle>

apiVersion --> Salesforce API version 45.0 or higher. Regardless of apiVersion, 
the component always uses the latest version of Lightning Data Service and base 
Lightning components. The Lightning Locker version is set at the org level, and 
isn't related to the component apiVersion.

isExposed  --> If isExposed is true component is exposed to Lightning App Builder or Experience Builder.

description --> A short description of the component. The description appears in list views, like the list of Lightning Components in Setup, and as a tooltip in Lightning App Builder and Experience Builder.

targets --> Specifies where the component can be added as explain below.

 lightning__AppPage -->  // Component available for app page.
 lightning__RecordPage -->  // Component available for record detail page.
 lightning__HomePage -->  // Component available for app home page.
 lightningCommunity__Default --> // Component can be used in community as default page.     

lightningCommunity__Page -->  // Component available for community as page.
lightning__Tab -->  // Enables a component to be used in a custom tab in Lightning
Experience or the Salesforce mobile app.
lightning__RecordAction --> // Enables a component to be used as a quick action on a record page.


For more details on XML Configuration File Elements visit below link: 


We can also create a .css file for styling purpose as shown in the below image. We can also create svg file for purpose of displaying icon.

Lightning Web Component Bundle

No comments:

Post a Comment