yuanqing / create-figma-plugin

:battery: The comprehensive toolkit for developing plugins and widgets for Figma and FigJam
https://yuanqing.github.io/create-figma-plugin/
MIT License
935 stars 89 forks source link

How to watch & build when working with different structure ? #225

Closed anup-a closed 6 months ago

anup-a commented 7 months ago

I'm trying to build a figma plugin out of my web app (nextjs, tailwind), with goal of reusing most of my components.

-- src
-- common
-- core
-- plugins
    -- figma
        --  build
        --  src
        -- manifest.json
-- package.json

My package.json

  "scripts": {
    "dev": "next",
    "build": "GENERATE_SOURCEMAP=false next build",
    "start": "next start",

    "plugin-build": "npm run plugin-build:css && npm run plugin-build:js",
    "plugin-build:css": "tailwindcss --input ./plugins/figma/src/styles/input.css --output ./plugins/figma/src/styles/output.css",
    "plugin-build:js": "build-figma-plugin --typecheck --minify -o ./plugins/figma",
    "plugin-watch": "npm run plugin-build:css && concurrently npm:plugin-watch:css npm:plugin-watch:js",
    "plugin-watch:css": "tailwindcss --input ./plugins/figma/src/styles/input.css --output ./plugins/figma/src/styles/output.css --watch",
    "plugin-watch:js": "build-figma-plugin --watch -o ./plugins/figma"
  },

I presume my issue would be resolved if I could specify the watch directory (same for typecheck). But I don't see that option in arguments.

So, back to my question. How can I watch & build when working with different structures?

yuanqing commented 6 months ago
  1. The build-figma-plugin CLI doesn’t currently support specifying the directory to build or watch. You’d need to cd into the appropriate directory before running it.
  2. The concurrently npm module might be relevant for your use case. See the plugins/preact-tailwindcss template.