@javier/figma-extractor

3.1.1 • Public • Published

figma-extractor

Node package that exports all the frames of a Figma file to different files.

Installation

yarn add figma-extractor

or

npm install figma-extractor

How to use it

const Extractor = require('figma-extractor')

let extractor = new Extractor(FIGMA_TOKEN, FIGMA_FILE)

extractor.extract().then((files) => {
  console.log(files) 
}).catch((e) => {
  console.error(e)
})

Result

By default Figma Extractor will export SVG files to the current directory. The extract command will return the list of exported files in this format:

[
  { "filename": "Frame 1.svg", "page":"Page 1" },
  { "filename": "Frame 2.svg", "page":"Page 1" }, 
  { "filename": "Frame 3.svg", "page":"Page 1" }, 
  { "filename": "Frame 4.svg", "page":"Page 2" }
]

Customizing the export

const Extractor = require('figma-extractor')

let options = { 
  format: 'svg',         // file type (from the Figma API)
  svg_include_id: true,  // from the Figma API
  ..
  pageID: '123:0',       // specify a page
  append_frame_id: true, // appends the frame id to the filename
  append_page_name: true, // appends the page name to the filename
  use_pages_as_folders: true, // create subdirectories with the name of the page
  dont_overwrite: true   // don't overwrite existing files with the same name
}

const extractor = new Extractor(FIGMA_TOKEN, FIGMA_FILE, OPTIONS)

extractor.extract(IMAGE_PATH).then((files) => {
  console.log(files)
})
}

let destination = 'my_beautiful_designs'

let extractor = new Extractor(FIGMA_TOKEN, FIGMA_FILE, options)

extractor.extract(destination).then((files) => {
  console.log(files) 
}).catch((e) => {
  console.error(e)
})

Package Sidebar

Install

npm i @javier/figma-extractor

Weekly Downloads

0

Version

3.1.1

License

MIT

Unpacked Size

7.48 kB

Total Files

4

Last publish

Collaborators

  • javier