Plugin Development
Learn how to develop and extend the Figma Variables plugin.
Project Structure
plugin/
├── src/
│ ├── code.ts # Plugin main code
│ ├── ui.tsx # Plugin UI components
│ └── utils.ts # Utility functions
├── manifest.json # Plugin manifest
└── package.json # Dependencies
Development Workflow
- Make changes to the source code
- The development server will automatically rebuild
- Reload the plugin in Figma to see changes
Adding New Features
Creating a New Command
typescript
// src/code.ts
figma.commands.register('exportVariables', async () => {
const variables = await figma.variables.getLocalVariables()
// Your export logic here
})
Adding UI Components
typescript
// src/ui.tsx
import React from 'react'
export function ExportButton() {
return (
<button onClick={() => {
parent.postMessage({ pluginMessage: { type: 'export' } }, '*')
}}>
Export Variables
</button>
)
}
Testing
Unit tests:
bashpnpm run test
E2E tests:
bashpnpm run test:e2e
Debugging
- Open the developer console in Figma
- Use
console.log
for debugging - Check the plugin logs in the Figma developer tools