npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ray1618/gulp-inline

v0.1.4

Published

Inline styles and scripts into an html file.

Downloads

71

Readme

@ray1618/gulp-inline

Information

Clone of gulp-inline as it's curruntly not maintained anymore, added a nullcheck to fix the folowing error: TypeError: Cannot read properties of null (reading 'toString')

Build Status codecov npm version

Usage

var inline = require('gulp-inline')
  , uglify = require('gulp-uglify')
  , minifyCss = require('gulp-minify-css')
  , autoprefixer = require('gulp-autoprefixer');

gulp.src('public/index.html')
  .pipe(inline({
    base: 'public/',
    js: uglify,
    css: [minifyCss, autoprefixer({ browsers:['last 2 versions'] })],
    disabledTypes: ['svg', 'img', 'js'], // Only inline css files
    ignore: ['./css/do-not-inline-me.css']
  }))
  .pipe(gulp.dest('dist/'));

Replaces your <script> and <link> tags with the corresponding inlined files.

SVG support

Currently there are two supported methods:

  • <img> element with src attribute:

    <img src="/assets/icon.svg" class="MyClass" />

    which will be converted to something like

    <svg xmlns="http://www.w3.org/2000/svg" viewbox="..." class="MyClass">
      <circle ... />
      <path ... />
      etc.
    </svg>

    depending on what /assets/icon.svg contains

  • <svg> element with <use> child element:

    <svg>
      <use xlink:href="/assets/icon.svg#MyIdentifier"></use>
    </svg>

    Note that this method requires an ID matching the ID of target SVG root element.

    This is valid target SVG for the example above:

    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" id="MyIdentifier">
      ...
    </svg>

    while this is invalid:

    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
      ...
    </svg>

Options

Plugin options:

  • base - the root directory containing the files to be inlined
  • css - css transform (gulp plugin)
  • js - js transform (gulp plugin)
  • svg - svg transform (gulp plugin)
  • ignore - array of file paths to ignore and not inline (file paths as they appear in the source)
  • disabledTypes - array of types not to run inlining operations on (css, svg, js, img)

How to set options for uglify when used as plugin

Below is an example of how to pass options to uglify. In this case we tell uglify to not mangle function names.

var inline = require('gulp-inline')
  , uglify = require('gulp-uglify');

gulp.src('public/index.html')
  .pipe(inline({
    base: 'public/',
    js: function() {
      return uglify({
          mangle: false
      });
    }
  }))
  .pipe(gulp.dest('dist/'));