1

I'm trying to create a basic LWC for a Community which would be a button where Community admins could set the button text and the page value it should link to. I don't have any Problems, but when I try to deploy it fails with the following error:

No base file for markup://c:lwcCommunityButton

Trying to use the force:source:deploy command to deploy to a Dev Ed. Sandbox:

Thanks for any input.

lwcCommunityButton.html

    <template>
    <div class="slds-p-around_none slds-m-top_x-small slds-m-bottom_medium slds-m-horizontal_none">
        <lightning-layout>
            <lightning-layout-item flexibility="auto">
                <div class="custom-box slds-text-align_center">
                    <lightning-button variant="brand" label={ButtonLabel} title={ButtonLabel} onclick={handleClick}></lightning-button>
                </div>
            </lightning-layout-item>
        </lightning-layout>
    </div>
    <c-view-source source="lwc/lwcCommunityButton" slot="footer">
        Navigate to a standard page as defined in the component configuration.
    </c-view-source>
</template>

lwcCommunityButton.js

import { LightningElement, api } from 'lwc';
import { NavigationMixin } from 'lightning/navigation';

export default class LwcCommunityButton extends NavigationMixin(LightningElement) {

    @api ButtonLabel;
    @api ButtonPageName;

    handleClick() {
        this[NavigationMixin.Navigate]({
            type: "standard__namedPage",
            attributes: {
                pageName: LwcCommunityButton.ButtonPageName
            }
        })
    }
}

lwcCommunityButton.js-meta.xml

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="lwcCommunityButton">
    <apiVersion>45.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightningCommunity__Page</target>
        <target>lightningCommunity__Default</target>
    </targets>
    <targetConfigs>
        <targetConfig targets="lightningCommunity__Page, lightningCommunity__Default">
            <property name="ButtonLabel" type="String" />
            <property name="ButtonPageName" type="String" placeholder="Enter a Page Name here..."/>
        </targetConfig>
    </targetConfigs>
</LightningComponentBundle>
0

It looks like you cannot define a property for lightningCommunity__Page.

If you define any property you get that error. Remove that from component metadata and it will allow you to deploy .

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="lwcCommunityButton">
    <apiVersion>45.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightningCommunity__Page</target>
        <target>lightningCommunity__Default</target>
    </targets>
    <targetConfigs>
        <targetConfig targets="lightningCommunity__Default">
            <property name="ButtonLabel" type="String" />
            <property name="ButtonPageName" type="String" placeholder="Enter a Page Name here..."/>
        </targetConfig>
    </targetConfigs>
</LightningComponentBundle>
  • This worked. I had to keep the lightningCommunity__Page as a <target>, but removed it from the targets parameter in the <targetConfig> tag. Thanks @pranay-jaiswal ! – pielax Feb 26 at 17:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.