New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

gulp-minify-inline

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-minify-inline

Gulp plugin to uglify inline JS and minify inline CSS

latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
2.2K
7.57%
Maintainers
1
Weekly downloads
 
Created
Source

gulp-minify-inline NPM version Build Status

gulp-minify-inline is a gulp plugin that minifies inline JS and CSS. Works best with gulp-minify-html.

Uses cheerio to parse HTML, terser to minify JS and clean-css to minify CSS.

Installation

Install package with NPM and add it to your development dependencies:

npm install --save-dev gulp-minify-inline

Usage

Straightforward way:

var minifyInline = require('gulp-minify-inline');

gulp.task('minify-inline', function() {
  gulp.src('src/*.html')
    .pipe(minifyInline())
    .pipe(gulp.dest('dist/'))
});

Need a bit more control?

var minifyInline = require('gulp-minify-inline');

var options = {
  js: {
    output: {
      comments: true
    }
  },
  jsSelector: 'script[type!="text/x-handlebars-template"]',
  css: {
    level: {1: {specialComments: 0}}
  },
  cssSelector: 'style[data-do-not-minify!="true"]'
};

gulp.task('minify-inline', function() {
  gulp.src('src/*.html')
    .pipe(minifyInline(options))
    .pipe(gulp.dest('dist/'))
});

Options

Right now the following options are supported:

  • js contains parameters to pass to terser.minify() (for documetation refer to the project homepage). Set it to false to disable JS minification globally. Please note that the plugin defaults js.output.inline_script to true in order to combat XSS (contributed by @TimothyGu). This is quite useful in general but you might want to re-set it to false explicitly in (an extremely rare) case it breaks things for you.
  • jsSelector is passed to cheerio as a selector for script tags. This allows you to avoid minification of certain script tags (e.g. ones containing templates or other non-JS payload). Default: 'script'.
  • css contains parameters to pass to clean-css (for documetation refer to the project homepage). Set it to false to disable CSS minification globally.
  • cssSelector is passed to cheerio as a selector for style tags. This allows you to avoid minification of certain style tags. Default: 'style'.

LICENSE

MIT License

Keywords

gulpplugin

FAQs

Package last updated on 28 Jan 2019

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