[SalesForce] Lightning Component Static Resources in Site.com

I have a lightning component that's enabled for community builder (site.com). It uses some static resources, unfortunately the normal relative static resource path doesn't work in a Site.com context so if I use :


In the Site.com site the static resource is not found. So far the only solution I've found is hard coding the full path:


This is obviously not a good solution for components I intend to include in a managed package where the salesforce domain will change.

What is the best way to generate the static resource path in the tag so that it will work in all possible Lightning component contexts:

  • SF1
  • Site.com
  • Lightning App Builder
  • Lightning Components in Visualforce

and any other contexts I might have missed that can use lightning components?

Best Answer

We need to add required files under assets to access them in site.com. Seems like we can't directly use static resource from salesforce.

Manage --> Administration --> Go to site.com studio --> Assets --> import

After importing script files, we can refer them as below:

<ltng:require scripts="/Jquery.js"/>