Creating a Figma plugin is a great way to extend the functionality of Figma. Below is a basic setup to start a new Figma plugin project using JavaScript. This example includes the necessary files and structure to get you started.
Create the Project Structure:
Create the files and folders as shown in the project structure above.
Compile TypeScript:
Add a build script to your package.json and run it:
bash
npm run build
Test the Plugin:
Open Figma.
Go to Plugins > Development > Import Plugin....
Select the manifest.json file from your project directory.
Your plugin should now appear in the Plugins menu.
Running the Plugin
Use npm run watch to automatically compile TypeScript files when you make changes.
Reload the plugin in Figma to see your updates.
This setup provides a basic Figma plugin that creates a rectangle when a button in the UI is clicked. You can expand upon this by adding more functionality, improving the UI, and utilizing Figma's API to manipulate designs programmatically.