Configuring your project
Code Connect can be configured with a figma.config.json file, which must be located in your project root (e.g. alongside the package.json or .xcodeproj file).
Every platform supports some common configuration options, in addition to any platform-specific options.
Common configuration options
include and exclude
include and exclude are lists of globs for where to parse Code Connect files, and for where to search for your component code when using the interactive setup. include and exclude paths must be relative to the location of the config file.
{
"codeConnect": {
"include": [],
"exclude": ["test/**", "docs/**", "build/**"]
}
}
parser
Code Connect tries to determine your project type by looking at the root of your project directory:
- If a
package.jsoncontainingreactis found, your project is detected as React - If a
package.jsonis found and doesn't containreact, your project is detected as HTML - If a file matching
Package.swiftor*.xcodeprojis found, your project is detected as Swift - If a file matching
build.gradle.ktsis found, your project is detected as Jetpack Compose
If your project framework isn't detected correctly, you can override the project type by using the parser key in your figma.config.json file. Valid values are react, html, swift and compose.
{
"codeConnect": {
"parser": "react"
}
}
label
label lets you specify the label that appears in Figma for your Code Connect snippets. The label defaults to your project type, such as React. Setting a different label for the snippets in Dev Mode can be useful, such as for showing different versions of the code.
For HTML projects, Code Connect sets the default label based on HTML-based frameworks detected in the first ancestor package.json of the working directory which matches one of the following:
- If a
package.jsoncontainingangularis found, the label is set toAngular - If a
package.jsoncontainingvueis found, the label is set toVue - Otherwise, the label is set to
Web Components