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
- Host: GitHub
- URL: https://github.com/posthtml/posthtml-style-to-file
- Owner: posthtml
- License: mit
- Created: 2015-09-25T22:08:15.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2019-06-25T12:10:42.000Z (over 6 years ago)
- Last Synced: 2024-10-29T21:06:07.926Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 12.7 KB
- Stars: 12
- Watchers: 8
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
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 }
```
__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