Customize the Scratch Org Definition File

If you imagine your Dev Hub as a chef who knows how to “cook” Salesforce orgs, then you could think of Scratch Org Definition Files as recipes that tell the chef exactly what to cook.

In this exercise, you will…

  • Open the default scratch org definition file (project-scratch-def.json)
  • Customize the contents of the scratch org definition file
  • Review the customizations made to project-scratch-def.json

Open the default scratch org definition file (project-scratch-def.json)

Let’s start by opening up the scratch org definition file that was created by default with your Salesforce DX project.

  1. In the VS Code file explorer, open the config folder and click on the project-scratch-def.json file.

Customize the contents of the scratch org definition file

The default scratch org definition file is missing a few things that most ISV partners will want to have. Let’s customize it by copy/pasting the example below into the file in VS Code.

Replace the contents of project-scratch-def.json by copy/pasting the following:

{
    "orgName": "AppX Package Development Org",
    "edition": "Developer",
    "features": ["MaxApexCodeSize:10"],
    "settings" : {
        "orgPreferenceSettings": {
            "s1EncryptedStoragePref2": false
        },
        "securitySettings": {
            "sessionSettings": {
                "sessionTimeout": "TwelveHours"
            }
        }
    }
}

Review the customizations made to project-scratch-def.json

Here’s what the different items in the scratch org definition file do.

  1. orgName: Sets the name of any scratch orgs created with this definition.
  2. edition: Determines the starting template. Scratch orgs created from PBO Dev Hubs can use special partner edition scratch orgs (eg. Partner Developer and Partner Enterprise).
  3. features: Sets org features, and in some cases allows the setting of “features with values” that may allow special behavior, like increasing the Maximum Apex Code Size limit.
  4. s1EncryptedStoragePref2: Disables caching of Lightning components, something very useful to Lightning developers.
  5. sessionTimeout: Set a session timeout that’s longer than 2 hours to make it easier to leave an org in the morning and come back to work on it in the afternoon.

Updated: