# sass-ffi

> Get JS values from SASS/SCSS

Latest version **0.0.2** (published 2019-05-13) · MIT OR GPL-3.0-or-later license · 0 weekly downloads

## Install

```sh
npm install sass-ffi
pnpm add sass-ffi
yarn add sass-ffi
bun add sass-ffi
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2019-05-13 |
| First published | 2019-05-08 |
| Weekly downloads | 0 |
| License | MIT OR GPL-3.0-or-later |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 9.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | futpib |

## Links

- npm: https://www.npmjs.com/package/sass-ffi
- npm.io page: https://npm.io/package/sass-ffi

## Dependencies (2)

- [resolve](https://npm.io/package/resolve.md) ^1.10.1
- [dot-prop](https://npm.io/package/dot-prop.md) ^4.2.0

## Recent versions

- 0.0.2 (latest) — 2019-05-13
- 0.0.1 — 2019-05-08

## README

# SASS/SCSS FFI
[![Build Status](https://travis-ci.org/futpib/sass-ffi.svg?branch=master)](https://travis-ci.org/futpib/sass-ffi) [![Coverage Status](https://coveralls.io/repos/github/futpib/sass-ffi/badge.svg?branch=master)](https://coveralls.io/github/futpib/sass-ffi?branch=master)

Require JS values from SASS/SCSS

## Features

### `ffi-require($module-path, $property-path: null)`

#### Import all values from a `.js` file

```js
// themes.js

module.exports = {
	light: {
		color: 'white',
		background: 'black',
	},
	dark: {
		color: 'black',
		background: 'white',
	},
};
```

```scss
// themes.scss

$themes: ffi-require('./themes');

$theme-light: map-get($themes, 'light');
$theme-dark: map-get($themes, 'dark');

body.theme-light {
	color: map-get($theme-light, 'color');
	background: map-get($theme-light, 'background');
}

body.theme-dark {
	color: map-get($theme-dark, 'color');
	background: map-get($theme-dark, 'background');
}
```

#### Import a single property from a `.js` file

```js
// config.js

module.exports = {
	env: process.env,
};

```

```scss
// hack.scss

$node-env: ffi-require('./config, 'env.NODE_ENV');

body:after {
	content: $node-env;
};
```

## Install

```
yarn add sass-ffi
```

## Usage with Webpack

Simply replace `sass-loader` with `sass-ffi/webpack-loader`.

## Usage with `node-sass`

```js
const sass = require('node-sass');
const { withSassFfiOptions } = require('sass-ffi');

sass.render(withSassFfiOptions({
	/* your options here */
}), (err, result) => {
	console.log({ err, result });
});
```

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