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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@pasmurno/gpug

v0.0.1

Published

Gulp plugin for compiling Pug templates

Readme

gpug

Gulp plugin for compiling Pug templates to HTML.

gpug is a tiny, focused Gulp plugin that pipes your .pug files through the official Pug compiler and emits ready-to-serve HTML. It is a modern, dependency-light alternative to gulp-pug, built for ESM-first Gulp 4 pipelines with full TypeScript support.

Features

  • Compiles Pug templates to HTML using the official pug compiler (v3).
  • Renames output files to .html.
  • Resolves include / extends relative to the source file — file.path is passed to Pug as filename.
  • Provides template locals from options.data and the Vinyl file.data (file.data takes precedence).
  • Passes every Pug compile option through: pretty, doctype, basedir, filters, globals, and more.
  • Correct Gulp plugin semantics: null files pass through, stream files are rejected, and errors are wrapped in PluginError with the file path and stack trace.
  • Dual package (ESM + CJS) with type declarations for both module systems.

Install

npm install --save-dev @pasmurno/gpug

Requires Node.js 20+ and Gulp 4.

Usage

Basic

gulpfile.mjs:

import { src, dest } from "gulp";
import { gpug } from "@pasmurno/gpug";

export function html() {
  return src("src/pug/**/*.pug").pipe(gpug()).pipe(dest("dist"));
}

export default html;

src/pug/index.pug:

doctype html
html
  head
    title Hello, gpug!
  body
    p Hello, world!

Run:

gulp

Output: dist/index.html with the compiled markup.

Passing data to templates

Global data goes into options.data; per-file data goes into the Vinyl file.data. On a naming conflict, file.data wins:

import { src, dest } from "gulp";
import { gpug } from "@pasmurno/gpug";

export function html() {
  return src("src/pug/**/*.pug")
    .pipe(
      gpug({
        pretty: true,
        data: {
          siteName: "gpug",
          year: new Date().getFullYear(),
        },
      }),
    )
    .pipe(dest("dist"));
}

src/pug/index.pug:

footer © #{year} #{siteName}

Files with include / extends

Since file.path is passed to Pug as filename, relative include and extends resolve next to the source file automatically:

src/pug/page.pug:

include partials/head.pug
p Main content

src/pug/partials/head.pug:

head
  title Page

For absolute paths, provide basedir:

import path from "node:path";
import { src, dest } from "gulp";
import { gpug } from "@pasmurno/gpug";

export function html() {
  return src("src/pug/**/*.pug")
    .pipe(gpug({ basedir: path.resolve("src/pug") }))
    .pipe(dest("dist"));
}

Error reporting

Compile errors are wrapped in a PluginError with plugin: 'gpug', the offending file path in fileName, and the stack trace enabled (showStack: true), so Gulp reports the exact template and the reason.

API

gpug(options?: GpugOptions): Transform

Creates a Vinyl transform stream. Accepts the same options as the Pug compiler, plus data.

Options

GpugOptions extends Pug's Options:

| Option | Type | Default | Description | | ------------------------ | ------------------------------------------- | ----------- | ----------------------------------------------------------------------------------------------------- | | data | Record<string, unknown> | {} | Globals available in every template as locals. Merged with file.data; file.data takes precedence. | | filename | string | file.path | Always overridden — Pug resolves relative include / extends against the source file path. | | basedir | string | — | Root directory used to resolve absolute include / extends paths. | | doctype | string | 'html' | Default doctype for the compiled HTML. | | pretty | boolean / string | false | Pretty-print the output. | | filters | Record<string, (text, options) => string> | — | Custom Pug filters. | | globals | string[] | — | Names of global objects to expose in templates. | | self | boolean | false | Use a self namespace instead of locals. | | compileDebug / debug | boolean | — | Pug debug options. |

Any other Pug Options values are accepted and forwarded to the compiler as-is.

Behavior

  • Output: file contents are replaced with the compiled HTML and file.extname becomes .html.
  • Null files (for example, directories passed through the pipeline) pass through unchanged.
  • Stream files are rejected with PluginError('Streams are not supported') — use buffered files (the default for gulp.src()).
  • Other content types produce PluginError('Unsupported file contents type').
  • Compile errors are wrapped in PluginError including the file path and stack trace.

TypeScript

The package ships type declarations for both ESM and CommonJS consumers:

import { gpug } from "@pasmurno/gpug";

gpug({
  data: { siteName: "gpug" },
  pretty: true,
});

Keywords

gulp, pug, jade, templates, compile, html

License

MIT ©2026 pasmurno by llcawc (github.com/llcawc). Made with ❤ for beautiful architecture.