New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gulp-html-css

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-html-css

A Gulp plugin for processing CSS within HTML. It compiles and transforms CSS in style tags and inline styles using PostCSS.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-57.14%
Maintainers
0
Weekly downloads
 
Created
Source

gulp-html-css

version Codecov release node.js license

[ English | 中文 ]

A Gulp plugin for processing CSS within HTML.

It compiles and transforms CSS in <style> tags and inline styles using PostCSS.
If a <style lang=""> attribute exists, it compiles the content using the appropriate preprocessor before applying PostCSS.

Features

  • Handle CSS within <style/> tag
  • Handle inline styles
  • Support for CSS preprocessor in the <style lang=""/>(Sass、Less、Stylus)
  • Using PostCSS to transform CSS
  • Supports merge postcss.config.js

Installation

npm install --save-dev gulp-html-css

Usage

const gulp = require('gulp')
const htmlCss = require('gulp-html-css')

gulp.task('process-html', () => {
  return gulp
    .src('src/**/*.html')
    .pipe(
      htmlCss(
        [
          /* PostCSS plugins */
        ],
        {
          /* options */
        }
      )
    )
    .pipe(gulp.dest('dist'))
})

API

htmlCss(plugins, options, ext)

plugins

Type: Array | Object

PostCSS plugins to be used for processing CSS.

options

Type: Object

Configuration options for the plugin.

  • postcss: Object - PostCSS options
  • compiler: Object - CSS preprocessor compiler (e.g., Sass, Less, Stylus)
  • compilerOptions: Object - Options for the preprocessor

ext

Type: Object | boolean

Extended configuration. If set to true or { merge: true }, it will merge with the existing PostCSS config.

Example

const gulp = require('gulp')
const htmlCss = require('gulp-html-css')
const autoprefixer = require('autoprefixer')
const cssnano = require('cssnano')
const sass = require('sass')

gulp.task('process-html', () => {
  return gulp
    .src('src/**/*.html')
    .pipe(
      htmlCss([autoprefixer(), cssnano()], {
        compiler: sass,
        compilerOptions: {
          // Sass options
        },
        postcss: {
          // PostCSS options
        },
      })
    )
    .pipe(gulp.dest('dist'))
})

This example processes HTML files, compiling Sass within <style lang="sass"> tags, then applies Autoprefixer and minifies the CSS using cssnano.

License

MIT

Keywords

FAQs

Package last updated on 23 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc