Create Static Resources in SFDX Source Format

Static resources can be a single file or a zipped collection of files.

  • If the resource is a collection of files, the SFDX CLI will automatically zip and unzip the files when it does a push or pull.
  • The default path in an SFDX project is force-app/main/default/staticresources

To create a new zipped resource

  • Create a new directory inside the staticresources directory and give it the name of the static resource.
  • Add a metadata file in the new directory with the name: <folder name>.resource-meta.xml
  • Add the following content to the body of metadata file.
<?xml version="1.0" encoding="UTF-8"?>
<StaticResource xmlns="http://soap.sforce.com/2006/04/metadata">
    <cacheControl>Public</cacheControl>
    <contentType>application/zip</contentType>
</StaticResource>

The files contained in the new directory will get zipped and uploaded as a new resource on the next push.


You'll only receive email when they publish something new.

More from Scott McClung
All posts