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

https://github.com/posthtml/posthtml-style-to-file

Save DOM styles to CSS file
https://github.com/posthtml/posthtml-style-to-file

Last synced: 7 months ago
JSON representation

Save DOM styles to CSS file

Awesome Lists containing this project

README

          

[![NPM][npm]][npm-url]
[![Deps][deps]][deps-url]
[![Tests][travis]][travis-url]
[![Coverage][cover]][cover-url]




Style-to-File Plugin


Save DOM styles to CSS file


Install

```bash
npm i -D posthtml-style-to-file
```

Usage

## Options

#### `path`

Type: `String`
Default: `./result.css`
Description: *Destination path, where the extracted CSS is saved to.*

#### `removeStyle`

Type: `String`
Default: ``
Description: *Removes the specified value `attrs` | `tag` | `all`*

__`removeStyle`__

Destination path, where the extracted CSS is saved to.

Example

```js
const posthtml = require('posthtml')
const styleToFile = require('posthtml-style-to-file')

const html = readFileSync('path/to/html', 'utf8')

posthtml([ styleToFile({ path: './dist/style.css' }) ])
.process(html)
.then((result) => console.log(result.html))
```

__index.html__

```html

Wow

html { margin: 0 }



Text

```

__style.css__

```css
html{ margin: 0 }
body{ background: #fff; }
div.button{ border: 1px solid #000; }
```

[npm]: https://img.shields.io/npm/v/posthtml-style-to-file.svg
[npm-url]: https://npmjs.com/package/posthtml-style-to-file

[deps]: https://david-dm.org/posthtml/posthtml-style-to-file.svg
[deps-url]: https://david-dm.org/posthtml/posthtml-style-to-file

[style]: https://img.shields.io/badge/code%20style-standard-yellow.svg
[style-url]: http://standardjs.com/

[travis]: http://img.shields.io/travis/posthtml/posthtml-style-to-file.svg
[travis-url]: https://travis-ci.org/posthtml/posthtml-style-to-file

[cover]: https://coveralls.io/repos/github/posthtml/posthtml-style-to-file/badge.svg
[cover-url]: https://coveralls.io/github/posthtml/posthtml-style-to-file