Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/thompsongl/postcss-class-prefix

No Longer Maintained - A class prefixer/namespacer for postcss
https://github.com/thompsongl/postcss-class-prefix

Last synced: 9 days ago
JSON representation

No Longer Maintained - A class prefixer/namespacer for postcss

Lists

README

        

# postcss-class-prefix [![Build Status](https://secure.travis-ci.org/thompsongl/postcss-class-prefix.png?branch=master)](http://travis-ci.org/thompsongl/postcss-class-prefix)
___

## ⚠️ Repo no longer actively maintained
Please look to [postcss-prefixer](https://github.com/marceloucker/postcss-prefixer) or [postcss-slds-prefix](https://github.com/salesforce-ux/postcss-slds-prefix) for similar functionallity in active repos.

___

A [PostCSS](https://github.com/postcss/postcss) plugin to prefix/namespace classes.

Avoid collisions with other libraries/stylesheets by prefixing your components with a namespace.

__Example input__

```css
.Component { /* ... */ }
.Component--modifier { /* ... */ }
.Component-descendent { /* ... */ }
```

__Example output__
`classPrefix('pfx-')`
```css
.pfx-Component { /* ... */ }
.pfx-Component--modifier { /* ... */ }
.pfx-Component-descendent { /* ... */ }
```

## Installation

```
npm install postcss-class-prefix
```

## Usage

```javascript
var fs = require('fs');
var postcss = require('postcss');
var classPrfx = require('postcss-class-prefix');

var css = fs.readFileSync('css/my-file.css', 'utf8').toString();
var out = postcss()
.use(classPrfx('my-prefix-'))
.process(css);
```

### Using the `ignore` option

```javascript
var fs = require('fs');
var postcss = require('postcss');
var classPrfx = require('postcss-class-prefix');

var css = fs.readFileSync('css/my-file.css', 'utf8').toString();
var out = postcss()
.use(classPrfx('my-prefix-', { ignore: [/ng-/, 'some-class-to-ignore']}))
.process(css);
```

## License

MIT

## Acknowledgements

* Based on [rework-class-prefix](https://github.com/jnv/rework-class-prefix) ([originally](https://github.com/johnotander/rework-class-prefix))