Skip to content
PostCSS Plugin
Branch: master
Clone or download
Latest commit 5fc85b6 Nov 29, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test test: add test for issue #10 Nov 29, 2017
.editorconfig
.gitignore added to .ignore sublime config files Jun 22, 2016
.npmignore chore: this config not need in npm repositories, close #9 Nov 29, 2017
.travis.yml CI(.travis) drop support 0.12 nodejs Nov 29, 2017
LICENSE docs(LICENSE): update LICENSE Jul 7, 2016
README.md Documentation fix for filterType Dec 6, 2016
index.js fix: plugin for postcss must be function, close #10 Nov 29, 2017
package-lock.json 0.2.6 Nov 29, 2017
package.json 0.2.6 Nov 29, 2017

README.md

NPM Deps Tests Coverage

PostCSS Plugin

Use PostCSS in HTML

Install

npm i -D posthtml-postcss

Usage

const { readFileSync } = require('fs')

const posthtml = require('posthtml')
const postcss = require('posthtml-postcss')

const postcssPlugins = []
const postcssOptions = {}
const filterType = /^text\/css$/

const html = readFileSync('./index.html', 'utf8')

posthtml([ postcss(postcssPlugins, postcssOptions, filterType) ])
    .process(html)
    .then((result) => console.log(result.html))

Example

const posthtml = require('posthtml')
const postcss = require('posthtml-postcss')

const postcssPlugins = [
  require('autoprefixer')({ browsers: ['last 2 versions'] })
]
const postcssOptions = {}
const filterType = /^text\/css$/

const html = `
  <style>div { display: flex; }</style>
  <div style="display: flex;">Text</div>
`

posthtml([ postcss(postcssPlugins, postcssOptions, filterType) ])
    .process(html)
    .then((result) => console.log(result.html))
<style>
  div { display: -webkit-flex;display: -ms-flexbox;display: flex; }
</style>
<div style="display: -webkit-flex;display: -ms-flexbox;display: flex;">
  Text
</div>

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.

You can’t perform that action at this time.