parcel-plugin-pug
raw JSON → 0.3.1 verified Sat Apr 25 auth: no javascript maintenance
Pug template support for Parcel bundler. Current stable version is 0.3.1. Maintenance mode: last release 2020, Parcel v1 only. Handles .pug and .jade files, resolves includes/extended templates and assets inside files. Requires Parcel 1.x, not compatible with Parcel v2.
Common errors
error Cannot find module 'parcel-bundler/src/Asset' ↓
cause parcel-bundler peer dependency not installed
fix
npm install -D parcel-bundler@^1.1.0
error asset.shouldInvalidate is not a function ↓
cause Incompatible with newer Parcel v1 versions (after v1.12.3)
fix
Use parcel-bundler@1.12.3 or lower, or update plugin to v0.2.5+
Warnings
breaking Parcel v2 is not supported; the plugin only works with Parcel v1. ↓
fix Use Parcel v1 (parcel-bundler@^1.1.0) or migrate to Parcel v2's built-in Pug support.
gotcha Plugin requires parcel-bundler as a peer dependency; missing it causes 'Cannot find module' error. ↓
fix Run npm install -D parcel-bundler@^1.0.0 in project.
deprecated Parcel v1 itself is deprecated; consider migrating to Parcel v2. ↓
fix Upgrade to Parcel v2 and use its native Pug support or community alternatives.
Install
npm install parcel-plugin-pug yarn add parcel-plugin-pug pnpm add parcel-plugin-pug Imports
- default wrong
const plugin = require('parcel-plugin-pug')correctInstall and use via Parcel (no explicit import needed) - PugAsset wrong
import { PugAsset } from 'parcel-plugin-pug'correctconst PugAsset = require('parcel-plugin-pug/src/Asset') - PugPlugin wrong
import PugPlugin from 'parcel-plugin-pug'correctmodule.exports = require('parcel-plugin-pug')
Quickstart
// Install Parcel v1 and plugin
npm install -D parcel-bundler@1 parcel-plugin-pug
// Create index.pug:
doctype html
html
head
title Parcel + Pug
body
h1 Hello World
p This is a Pug template bundled with Parcel.
img(src="image.jpg" alt="test")
// Run:
// npx parcel index.pug
// Opens localhost:1234 with compiled HTML.