1

I make/deploy my APEX and LWC components through VS Code and SFDX and recently ran into a problem where, when I went to deploy a lwc to another sandcopy, I noticed that the folder/file structure I had created in VS code was completely gone in the new sandbox. Hindsight I can now see (I assume) that salesforce don't deploy the file structure from VS Code to SF.

My structure looks like this:

main
-- default  
---- lwc  
------ <My Lightning Web Component>  
--------- A subcomponent used in <My Lightning Web Component>  
--------- Another component used in <My Lightning Web Component> 

But when i deploy them to another org using an outbound changeset, it looks like this:

main
-- default    
---- lwc  
---- <My Lightning Web Component>  
---- A subcomponent used in <My Lightning Web Component>
---- Another component used in <My Lightning Web Component> 

My question is: How do I maintain the initial structure when deploying to another org. As projects grow in size, this is of course vital, and I realise that there has to be a solution for this - I just haven't been able to find anything myself

Thanks, Joe

1 Answer 1

1

The sfdx structure is meant to be used in a repo. The folder structure is not uploaded to Salesforce during sfdx deployments, and thus cannot later be retrieved. You can deploy the same code to multiple orgs using sfdx, and can even push/pull from multiple scratch orgs, as the metadata is saved per org in the sfdx configuration files.

7
  • Thanks for the reply. How exactly would I go about pushing my code from one org to another while maintaining the file structure with SFDX? Thanks ...
    – Carl-Johan
    Commented Oct 22, 2019 at 15:18
  • @Carl-JohanBeurling sfdx force:source:deploy -p file-path -u target-org deploys code from your local repo to an org. In DX, you don't really deploy directly from one org to another, but instead use your repo as the "source of truth."
    – sfdcfox
    Commented Oct 22, 2019 at 15:30
  • thanks for the quick reply! My problem is currently that when I retrieve the code with sfdx, the new classes arent in the package.xml and therefore aren't retrieved ...
    – Carl-Johan
    Commented Oct 22, 2019 at 15:37
  • @Carl-JohanBeurling You can use sfdx force:source:retrieve -m ApexClass:ClassName1,ClassName2,... to retrieve specific classes that are not in a package.xml, or even just sfdx force:source:retrieve -m ApexClass to retrieve all classes (and you can do this with most metadata types).
    – sfdcfox
    Commented Oct 22, 2019 at 15:46
  • Is it a problem if all my classes are contained in a top-level folder? When I look at the logs from the deploy command everything seems fine (the file structure is maintained), but when I retrieve them, the components are all placed top-level (default/classes) ??
    – Carl-Johan
    Commented Oct 22, 2019 at 15:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .