Newer Version Available

This content describes an older version of this product. View Latest

Create a Salesforce DX Project

A Salesforce DX project has a specific structure and a configuration file that identifies the directory as a Salesforce DX project.
Before you create your project, first decide if you’re following org-based or package-based project development model.

If you’re following org-based development, change to the directory where you want the DX project located. Then run force:project:create -n MyProject --manifest to generate your project with a default manifest (package.xml) file.

If you’re following package-based development, you can create a project with minimal (empty) or expanded (standard) scaffolding. The default is standard, which provides extended scaffolding to facilitate moving source to and from your orgs.
  1. Change to the directory where you want the DX project located.
  2. Create the DX project.
    1sfdx force:project:create -n MyProject
    If you don’t indicate an output directory, the project directory is created in the current location. You can also specify the default package directory to target when syncing source to and from the scratch org. If you don’t indicate a default package directory, this command creates a default package directory, force-app.

    If you don’t choose a template type, the default is --template standard. The standard template provides a complete directory structure that takes the guesswork out of where to put your source. It also provides these files that are especially helpful when using Salesforce Extensions for VS Code.

    • .gitignore: Makes it easier to start using Git for version control.
    • .prettierrc and .prettierignore: Make it easier to start using Prettier to format your Aura components.
    • .vscode/extensions.json: Causes Visual Studio Code, when launched, to prompt you to install the recommended extensions for your project.
    • .vscode/launch.json: Configures Replay Debugger, making it more discoverable and easier to use.
    • .vscode/settings.json: By default, this file has one setting, for push or deploy on save, which is set to false. You can change this value or add other settings.

    If you choose --template empty, your project contains these sample configuration files to get you started.

    • .forceignore
    • config/project-scratch-def.json
    • sfdx-project.json
    • package.json

    If you choose --template analytics, you get all helpful VS Code files but the project scaffolding contains only one directory: /force-app/main/default/waveTemplates.

Example

1sfdx force:project:create --projectname mywork --template standard
1sfdx force:project:create --projectname mywork --defaultpackagedir myapp

Next steps:

  • (Optional) Register the namespace with the Dev Hub org.
  • Configure the project (sfdx-project.json). If you use a namespace, update this file to include it.
  • Create a scratch org definition that produces scratch orgs that mimic the shape of another org you use in development, such as sandbox, packaging, or production. The config directory of your new project contains a sample scratch org definition file (project-scratch-def.json).