Normally Palatable Mango

    posthtml-style-to-file

    0.2.0 • Public • Published

    NPM Deps Tests Coverage

    Style-to-File Plugin

    Save DOM styles to CSS file

    Install

    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

    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>
    <head>
        <title>Wow</title>
        <style type="text/css">
            html { margin: 0 }
        </style> 
    </head>
    <body style="background: #fff;">
      <div class="button" style="border: 1px solid #000;">
        <div class="button__text">
            Text
        </div>
      </div>
    </body>
    </html>

    style.css

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

    LICENSE

    MIT License (MIT)

    Copyright (c) PostHTML Ivan Voischev voischev.ivan@ya.ru

    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

    Install

    npm i posthtml-style-to-file

    DownloadsWeekly Downloads

    10

    Version

    0.2.0

    License

    MIT

    Unpacked Size

    13.7 kB

    Total Files

    10

    Last publish

    Collaborators

    • voischev