# postcss-define-function

> PostCSS plugin : A plugin to implement sass @function directive

Latest version **0.1.2** (published 2019-07-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install postcss-define-function
pnpm add postcss-define-function
yarn add postcss-define-function
bun add postcss-define-function
```

## 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.1.2 |
| Published | 2019-07-08 |
| First published | 2017-01-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 13.4 KB |
| Known vulnerabilities | 0 (+6 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 27 |
| Author | mcattx |
| Maintainers | mcattx |
| Keywords | postcss, css, postcss-plugin, define, function, directive, sass |

## Links

- npm: https://www.npmjs.com/package/postcss-define-function
- Repository: https://github.com/titancat/postcss-define-function
- Issues: https://github.com/titancat/postcss-define-function/issues
- npm.io page: https://npm.io/package/postcss-define-function

## Dependencies (1)

- [postcss](https://npm.io/package/postcss.md) ^5.2.6

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 0.1.2 (latest) — 2019-07-08
- 0.1.1 — 2017-01-08
- 0.1.0 — 2017-01-08

## README

# PostCSS define-function [![Build Status][ci-img]][ci]

[PostCSS] plugin to implement sass @function.

[PostCSS]: https://github.com/postcss/postcss
[ci-img]:  https://travis-ci.org/titancat/postcss-define-function.svg
[ci]:      https://travis-ci.org/titancat/postcss-define-function

```css
@define-function rem($val) {
    @return $val / 640 * 10 * 1rem;
}
@callFn .foo {
    /* Input example */
    height: rem(640);
}
```

```css
.foo {
  /* Output example */
  height: 10rem}
```

**It only supports the basic four mixed operations: `+`、`-`、`*`、`/`. If you want to be able to use more advanced features, you can use [mixins](https://github.com/postcss/postcss-mixins) instead or help me to improve it.**

**Looking forward to your [issues](https://github.com/titancat/postcss-define-function/issues) and [pull requests](https://github.com/titancat/postcss-define-function/pulls)**

## Usage

```js
postcss([ require('postcss-define-function') ])
```

See [PostCSS] docs for examples for your environment.

## Options

Call plugin function to set options:

```js
postcss([ require('postcss-define-function')({ silent: true }) ])
```

### `silent`
Remove unknown callFns and do not throw a error. Default is `false`.

## Test
```js
// basic feature test
npm test
// preview visual test results
npm run testCase
```

## Thanks

- [postcss](https://github.com/postcss/postcss)
- [postcss-plugin-boilerplate](https://github.com/postcss/postcss-plugin-boilerplate)
- [postcss-mixins](https://github.com/postcss/postcss-mixins)

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