Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Modern Gulp plugin for Pug 3.x template compilation - Fast HTML generation from Pug templates with source maps, filters, and full Pug API support. Actively maintained.

License

Notifications You must be signed in to change notification settings

orcunsaltik/gulp-pug-3

Repository files navigation

gulp-pug-3

CI npm version npm downloads node version license

Modern Gulp plugin for Pug 3.x template compilation - Fast HTML generation from Pug templates with source maps, filters, and full Pug API support. Actively maintained.

Compiles your Pug templates into HTML or JavaScript easily and always uses the latest stable version of Pug.

Features

  • ✅ Supports the latest Pug version (3.x)
  • ✅ Compiles to HTML or JS
  • ✅ Custom locals and options
  • ✅ Works with Gulp 4.x
  • ✅ Modern Node.js support (18+)

Installation

npm install --save-dev gulp-pug-3

Usage

Basic Example

const { src, dest } = require('gulp');
const pug = require('gulp-pug-3');

function compilePug() {
  return src('src/**/*.pug')
    .pipe(
      pug({
        // Your options here
      })
    )
    .pipe(dest('dist'));
}

exports.default = compilePug;

With Options

const { src, dest } = require('gulp');
const pug = require('gulp-pug-3');

function compilePug() {
  return src('src/**/*.pug')
    .pipe(
      pug({
        locals: {
          siteName: 'My Website',
          lang: 'en',
        },
        pretty: true,
        basedir: __dirname + '/src',
      })
    )
    .pipe(dest('dist'));
}

exports.default = compilePug;

Compile to JavaScript

const { src, dest } = require('gulp');
const pug = require('gulp-pug-3');

function compilePugToJs() {
  return src('src/**/*.pug')
    .pipe(
      pug({
        client: true,
        extension: '.js',
      })
    )
    .pipe(dest('dist'));
}

exports.default = compilePugToJs;

API

In addition to Pug's standard options, the following options are available:

client

Type: Boolean Default: false

Compile to JavaScript template function instead of HTML.

extension

Type: String Default: .html (or .js if client: true)

Output file extension.

locals

Type: Object Default: {}

Data to pass to Pug templates. Can also be set via file.data (e.g., with gulp-data).

Other Pug Options

All standard Pug options are supported:

  • filename
  • basedir
  • doctype
  • pretty
  • filters
  • self
  • debug
  • compileDebug
  • globals
  • cache
  • inlineRuntimeFunctions
  • name

See Pug documentation for details.

Requirements

  • Node.js >= 18.0.0
  • Gulp >= 4.0.0

Changelog

v2.0.2 (2025)

  • 🚀 Updated config files to latest standards
  • 🚀 Improved development workflow
  • 🚀 Better code quality tools
  • 🚀 Updated SEO-friendly package description

v2.0.1 (2025)

  • Dependency updates

v2.0.0 (2025)

  • 🚀 Updated to Pug 3.0.3
  • 🚀 Modernized dependencies
  • 🚀 Added GitHub Actions CI
  • 🚀 Improved code quality with Prettier & ESLint
  • 🚀 Node.js 18+ support

v1.2.2 (2021)

  • Previous stable release

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Troubleshooting

When you encounter a problem, please open an issue. I would be glad to help you find a solution.

Author

Orçun Saltık

License

MIT © Orçun Saltık

About

Modern Gulp plugin for Pug 3.x template compilation - Fast HTML generation from Pug templates with source maps, filters, and full Pug API support. Actively maintained.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •