# postcss-styl

> PostCSS parser plugin for converting Stylus syntax to PostCSS AST.

Latest version **0.12.3** (published 2023-01-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install postcss-styl
pnpm add postcss-styl
yarn add postcss-styl
bun add postcss-styl
```

## 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.12.3 |
| Published | 2023-01-11 |
| First published | 2019-07-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | ^8.10.0 \|\| ^10.13.0 \|\| ^11.10.1 \|\| >=12.13.0 |
| Dependencies | 5 |
| Unpacked size | 149.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Yosuke Ota |
| Maintainers | ota-meshi, ichenlei |
| Keywords | postcss, stylus, styl, parser, stringifier, syntax, css |

## Links

- npm: https://www.npmjs.com/package/postcss-styl
- Repository: https://github.com/stylus/postcss-styl
- Homepage: https://github.com/stylus/postcss-styl#readme
- Issues: https://github.com/stylus/postcss-styl/issues
- Funding: https://opencollective.com/stylus
- npm.io page: https://npm.io/package/postcss-styl

## Dependencies (5)

- [debug](https://npm.io/package/debug.md) ^4.1.1
- [stylus](https://npm.io/package/stylus.md) ^0.57.0
- [postcss](https://npm.io/package/postcss.md) ^7.0.27 || ^8.0.0
- [fast-diff](https://npm.io/package/fast-diff.md) ^1.2.0
- [lodash.sortedlastindex](https://npm.io/package/lodash.sortedlastindex.md) ^4.1.0

## 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.12.3 (latest) — 2023-01-11
- 0.12.2 — 2023-01-08
- 0.12.1 — 2023-01-08
- 0.12.0 — 2023-01-08
- 0.11.1 — 2022-06-17
- 0.11.0 — 2022-06-17
- 0.10.0 — 2022-06-16
- 0.9.0 — 2021-09-15
- 0.8.0 — 2021-01-28
- 0.7.2 — 2020-07-23
- 0.7.1 — 2020-04-25
- 0.7.0 — 2020-04-25
- 0.6.2 — 2020-04-25
- 0.6.1 — 2020-04-24
- 0.6.0 — 2020-04-24
- … 28 more at https://npm.io/package/postcss-styl/versions

## README

# postcss-styl

[![NPM license]](https://www.npmjs.com/package/postcss-styl)
[![NPM version]](https://www.npmjs.com/package/postcss-styl)
[![NPM downloads]](https://www.npmjs.com/package/postcss-styl)
[![Build Status]](https://github.com/stylus/postcss-styl/actions?query=workflow%3ACI)
[![Coverage Status]](https://coveralls.io/github/stylus/postcss-styl?branch=main)

[PostCSS] parser plugin for converting [Stylus] syntax to [PostCSS] AST.

:::
**_This plugin is still in an experimental state_**
:::

## Installation

```bash
npm install -D postcss-styl
```

## Usage

### Lint Stylus with [stylelint]

You can use this [PostCSS] plugin to apply [Stylus] syntax to [stylelint].  
**You can use it more easily by using it with [stylelint-plugin-stylus](https://github.com/stylus/stylelint-plugin-stylus).**

For example, this [PostCSS] plugin is used as follows:

1. First, add `customSyntax` option to `stylelint` config file.

   e.g. [stylelint.config.js](./stylelint.config.js)

   ```js
   // Filename: `stylelint.config.js`

   module.exports = {
      overrides: [
          {
              files: ["*.styl", "**/*.styl", "*.stylus", "**/*.stylus"],
              customSyntax: "postcss-styl",
          },
      ],
   };
   ```

2. You need to include the stylus in the linting target, as shown in the following example.

   - via CLI

     ```bash
     stylelint ./path/to/input.styl
     ```

   - with [VSCode extension]

     ```js
     {
       "stylelint.validate": [
          ...,
          // ↓ Add "stylus" language.
          "stylus"
       ]
     }
     ```

### Stylus Transformations

Also you can use this parser plugin to apply [PostCSS] transformations directly to the [Stylus] source code.

For example, [Stylus] sources can be automatically prefixed using [Autoprefixer].

```js
const postcss = require("postcss");
const autoprefixer = require("autoprefixer");
const postcssStyl = require("postcss-styl");

const stylusCode = `
a
  transform scale(0.5)
`;
postcss([autoprefixer])
  .process(stylusCode, {
    syntax: postcssStyl
  })
  .then(result => {
    console.log(result.css);
    // ->
    // a
    //   -webkit-transform scale(0.5);
    //   -moz-transform scale(0.5);
    //   transform scale(0.5)
  });
```

## Contributing

Welcome contributing!

Please use GitHub's Issues/PRs.

### Development Tools

- `npm test` runs tests and measures coverage.

### AST

You can check the AST online.  
https://stylus.github.io/postcss-styl/

## License

See the [LICENSE] file for license rights and limitations (MIT).

[postcss]: https://postcss.org/
[VSCode extension]: https://marketplace.visualstudio.com/items?itemName=stylelint.vscode-stylelint
[stylus]: http://stylus-lang.com/
[stylelint]: http://stylelint.io/
[autoprefixer]: https://github.com/postcss/autoprefixer
[postcss-syntax]: https://github.com/gucong3000/postcss-syntax
[license]: ./LICENSE
[npm license]: https://img.shields.io/npm/l/postcss-styl.svg
[npm version]: https://img.shields.io/npm/v/postcss-styl.svg
[npm downloads]: https://img.shields.io/npm/dw/postcss-styl.svg
[Build Status]: https://github.com/stylus/postcss-styl/workflows/CI/badge.svg?branch=main
[Coverage Status]: https://coveralls.io/repos/github/stylus/postcss-styl/badge.svg?branch=main

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