# figma-loader

> Figma to SVG URL loader module for webpack

Latest version **1.0.2** (published 2020-02-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install figma-loader
pnpm add figma-loader
yarn add figma-loader
bun add figma-loader
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2020-02-22 |
| First published | 2020-02-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=v10.16.3 |
| Dependencies | 5 |
| Unpacked size | 4.8 KB |
| Known vulnerabilities | 0 (+25 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Tobias Strebitzer |
| Maintainers | tstrebitzer |

## Links

- npm: https://www.npmjs.com/package/figma-loader
- Repository: https://github.com/MagLoft/figma-loader
- npm.io page: https://npm.io/package/figma-loader

## Dependencies (5)

- [axios](https://npm.io/package/axios.md) ^0.19.2
- [figma-js](https://npm.io/package/figma-js.md) ^1.9.0
- [fs-extra](https://npm.io/package/fs-extra.md) ^8.1.0
- [loader-utils](https://npm.io/package/loader-utils.md) ^1.4.0
- [find-cache-dir](https://npm.io/package/find-cache-dir.md) ^3.2.0

## Recent versions

- 1.0.2 (latest) — 2020-02-22
- 1.0.1 — 2020-02-22

## README

## figma-loader

Figma to SVG URL loader module for webpack.

## Install

`yarn add --dev figma-loader`

`npm install --save-dev figma-loader`

### Webpack Configuration

```js
module.exports = {
  ...
  module: {
    rules: [{
      test: /\.(figma)/,
      use: [{
        loader: 'figma-loader',
        options: { accessToken: 'FIGMA-PERSONAL-ACCESS-TOKEN' }
      }]
    }]
  }
}
```

## Figma Document Setup

1. Create a Figma document with frames on the top level of a page.
2. Assets are extracted by frame name.
3. For each Figma document used in your project, create a `*.figma` file containing the Figma File ID, e.g. `eMV7Sxpjs7y6HhnQyC0roR`

Here's an example of a figma document layout:

```
document 'icons'
  page 'Page 1'
    frame 'star'
    frame 'fish'
    frame 'facebook'
    frame 'twitter'
```

## Example usage in CSS

You can use the relative url to your figma document. Query parameter `frame` specified the target frame, and optional `color` tints the image.

```css
.icon-star { background-image: url(./icons.figma?frame=star); }
.icon-fish { background-image: url(./icons.figma?frame=fish); }
.icon-facebook { background-image: url(./icons.figma?frame=facebook); }
.icon-twitter { background-image: url(./icons.figma?frame=twitter&color=FF0000); }
```

## Example usage in JS

Import the 'icon' function, which generates a base64-encoded data-uri.

```js
// require your figma document
const { icon } = require('./icons.figma')

// generate star icon
const starIcon = icon('star')

// generate red star icon, by replacing 'black' color to '#FF0000'
const starIconRed = icon('star', '#FF0000')
```

---
_Source: https://npm.io/package/figma-loader · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
