├── .gitignore ├── src ├── ui │ ├── style.module.css │ ├── ui.html │ └── index.tsx └── figma │ └── index.ts ├── .prettierrc ├── .vscode └── settings.json ├── shims-css.d.ts ├── manifest.json ├── babel.config.json ├── tsconfig.json ├── README.md └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.log 3 | dist -------------------------------------------------------------------------------- /src/ui/style.module.css: -------------------------------------------------------------------------------- 1 | .foo { 2 | color: red; 3 | } 4 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": false, 3 | "singleQuote": true, 4 | "printWidth": 80, 5 | "trailingComma": "none" 6 | } -------------------------------------------------------------------------------- /src/ui/ui.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.defaultFormatter": "esbenp.prettier-vscode", 3 | "editor.formatOnSave": true 4 | } 5 | -------------------------------------------------------------------------------- /shims-css.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.css' { 2 | const content: { [className: string]: string } 3 | export default content 4 | } 5 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "your-plugin-name", 3 | "id": "your-plugin-id", 4 | "api": "1.0.0", 5 | "main": "dist/js/figma.js", 6 | "ui": "dist/ui.html" 7 | } 8 | -------------------------------------------------------------------------------- /babel.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "@babel/env", 5 | { 6 | "useBuiltIns": "usage", 7 | "corejs": 3 8 | } 9 | ] 10 | ], 11 | "plugins": [ 12 | [ 13 | "@hcysunyang/vue-next-jsx", 14 | { 15 | "source": "vue" 16 | } 17 | ] 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "outDir": "dist", 5 | "sourceMap": false, 6 | "target": "ESNext", 7 | "module": "ESNext", 8 | "moduleResolution": "node", 9 | "allowJs": false, 10 | "strict": true, 11 | "noUnusedLocals": true, 12 | "resolveJsonModule": true, 13 | "esModuleInterop": true, 14 | "removeComments": false, 15 | "jsx": "preserve", 16 | "lib": ["esnext", "dom"], 17 | "rootDir": ".", 18 | "typeRoots": ["./node_modules/@types", "./node_modules/@figma"] 19 | }, 20 | "include": ["src", "shims-css.d.ts"] 21 | } 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Vue3 Figma Plugin Starter 2 | 3 | Use Vue3 to build figma plugin 4 | 5 | - Use `webpack` to develop and build 6 | - Integrate [vue-next-jsx](https://github.com/HcySunYang/vue-next-jsx) for Vue3 `jsx/tsx` 7 | - Everything is out of the box 8 | 9 | ## Setup 10 | 11 | - clone this repo 12 | 13 | - install dependencies 14 | 15 | ```sh 16 | yarn 17 | # or 18 | yarn install 19 | ``` 20 | 21 | - Run dev 22 | 23 | ```sh 24 | yarn dev 25 | ``` 26 | 27 | - Run your plugin 28 | 29 |  30 | 31 |  32 | 33 | ## Note 34 | 35 | Remember to modify the `name` and `id` in the `manifest.json` file 36 | -------------------------------------------------------------------------------- /src/ui/index.tsx: -------------------------------------------------------------------------------- 1 | import { createApp, ref } from 'vue' 2 | import style from './style.module.css' 3 | 4 | createApp({ 5 | setup() { 6 | const refCount = ref(5) 7 | function handler() { 8 | parent.postMessage( 9 | { pluginMessage: { type: 'create-rectangles', count: refCount.value } }, 10 | '*' 11 | ) 12 | } 13 | 14 | function cancel() { 15 | parent.postMessage({ pluginMessage: { type: 'cancel' } }, '*') 16 | } 17 | 18 | return () => ( 19 |22 | Count: 23 |
24 | 27 | 30 |