# postcss-modules-parser

> A CSS Modules parser to extract tokens from the css file

Latest version **1.1.1** (published 2017-05-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install postcss-modules-parser
pnpm add postcss-modules-parser
yarn add postcss-modules-parser
bun add postcss-modules-parser
```

## 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.1.1 |
| Published | 2017-05-26 |
| First published | 2015-11-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.12 |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+6 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Alexey Litvinov |
| Maintainers | sullenor |
| Keywords | css-modules, postcss, css, postcss-plugin |

## Links

- npm: https://www.npmjs.com/package/postcss-modules-parser
- Repository: https://github.com/css-modules/postcss-icss
- Homepage: https://github.com/css-modules/postcss-icss#readme
- Issues: https://github.com/css-modules/postcss-icss/issues
- npm.io page: https://npm.io/package/postcss-modules-parser

## Dependencies (3)

- [postcss](https://npm.io/package/postcss.md) ^5.0.10
- [lodash.foreach](https://npm.io/package/lodash.foreach.md) ^3.0.3
- [icss-replace-symbols](https://npm.io/package/icss-replace-symbols.md) ^1.0.2

## 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

- 1.1.1 (latest) — 2017-05-26
- 1.1.0 — 2015-11-24
- 1.0.1 — 2015-11-03

## README

postcss-modules-parser
======================

A CSS Modules parser to extract tokens from the css file. Provides opportunity to process multiple files. Supports both synchronous and asynchronous file loaders.

## API

In order to use it you should provide a `fetch` function which should load contents of files and process it with the PostCSS instance. `fetch` function should return tokens or promise object which will resolve into tokens.

```javascript
var Parser = require('postcss-modules-parser');

/**
 * @param  {string} to   Path to the new file. Could be any.
 * @param  {string} from Path to the source file. Should be absolute.
 * @return {object}      Tokens
 */
function fetch(to, from) {
  // load content
  return instance.process(css, {from: filename}).root.tokens;
}

new Parser({fetch: fetch});
```

See the examples:
- asynchronous loader: [test/helper/async-loader.js](https://github.com/css-modules/postcss-modules-parser/blob/master/test/helper/async-loader.js)
- synchronous loader: [test/helper/sync-loader.js](https://github.com/css-modules/postcss-modules-parser/blob/master/test/helper/sync-loader.js)

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