gulp-html-postcss

Process inline CSS in HTML using PostCSS gulp plugin
229,532 5
Install
npm install gulp-html-postcss
Latest Version:7.1.4
License:MIT
Last Updated:Jul 27, 2018
Links: GitHub  ·  npm
Maintainer: gucong

gulp-html-postcss

NPM version Build Status Coverage Status

PostCSS gulp plugin with support for HTML and HTML-like:

Install

$ npm install --save-dev gulp-html-postcss

Install required postcss plugins separately. E.g. for autoprefixer, you need to install autoprefixer package.

Basic usage

The configuration is loaded automatically from postcss.config.js as described here, so you don't have to specify any options.

const postcss = require('gulp-html-postcss');
const gulp = require('gulp');

gulp.task('css', () => (
    gulp.src('./src/*.html')
        .pipe(postcss())
        .pipe(gulp.dest('./dest'))
));

Advanced usage

You can pass config as an {Object} as described here,

If you want to configure postcss on per-file-basis, you can pass a callback that receives ctx with the context options and the vinyl file. Described here,

const gulp = require('gulp');
const postcss = require('gulp-postcss');
const reporter = require('gulp-reporter');
const autoprefixer = require('autoprefixer');
const cssnano = require('cssnano');
const sugarss = require('sugarss');

gulp.task('css', () => {
    const callback = (ctx) => ({
        // Configure parser on per-file-basis.
        parser: ctx.file.extname === '.sss' ? 'sugarss' : false,
        // Plugins can be loaded in either using an {Object} or an {Array}.
        plugins: [
            autoprefixer,
            cssnano
        ]
    });

    return gulp.src('./src/*.html', {
        // Source map support
        sourcemaps: true
    })
        .pipe(postcss(callback))
        // Message repport support
        .pipe(reporter())
        .pipe(gulp.dest('./dest'));
});

Related Packages

the-themex-project

Themex aims to prevent a blank screen in your IDE and serves as a solid foundati...

7,230 18
nuxt-lightningcss

Lightningcss for Nuxt

1,663 6
vue-chartmaker

A Vue.JS Component for creating Charts in HTML and CSS

634
postcss-html

PostCSS syntax for parsing HTML (and HTML-like)

90,051,440 34
live-playground-3

HTML and CSS playground.

338 0

Version History

Version Released License
7.1.4 MIT
7.1.3 MIT
7.1.2 MIT
7.1.1 MIT
7.1.0 MIT