Registry / web-framework / vite-plugin-pug

vite-plugin-pug

JSON →
library0.4.1jsnpmunverified

Vite plugin that transforms <pug> tags in HTML into compiled Pug templates. Current stable version is 0.4.1, supporting Vite 5. Releases follow no strict cadence; last update (v0.4.1) added Vite 5 support. Key differentiators: supports local variables, multiple pug tags, self-closing tags, hot reload on save, and works with both CJS and ESM. Ships TypeScript declarations. Simpler than alternatives that require Vue SFCs for Pug support.

npm install vite-plugin-pug
INSTALL
IMPORT
SIG · VITE-PLUGIN-PUG
V
vite-plugin-pug
web-frameworkjavascriptv0.4.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (pugPlugin)
import pugPlugin from 'vite-plugin-pug'
const pugPlugin = require('vite-plugin-pug')
ESM-only; CJS require works but not recommended since v0.3.1 ships ESM only.
default (pugPlugin)
import pugPlugin from 'vite-plugin-pug'
import { pugPlugin } from 'vite-plugin-pug'
The package exports a default function, not a named export.
Type (PluginOptions)
import type { PluginOptions } from 'vite-plugin-pug'
TypeScript users can import the PluginOptions type for better intellisense.

Configures Vite to use vite-plugin-pug with Pug pretty-printing option and local variables.

// vite.config.ts import { defineConfig } from 'vite' import pugPlugin from 'vite-plugin-pug' const options = { pretty: true, basedir: process.cwd() } const locals = { name: 'World' } export default defineConfig({ plugins: [pugPlugin(options, locals)], })
Debug
Known issues
deprecatedPug option `pretty` is deprecated in Pug 3 and will be removed.
fix
Remove `pretty` from plugin options, or use pug's built-in formatting via beautifier.
affects: >=0.1.0
breakingv0.3.0 changed to only accept `options` (pug options) and `locals` (data) as separate parameters, rather than a single object.
fix
Update config: `pugPlugin(options, locals)` instead of `pugPlugin({locals, ...})`.
affects: >=0.3.0
gotchaLocal imports (`localImports` option) only work when the pug `src` attribute is a relative path. Does not support absolute paths or module resolution.
fix
Ensure all pug src paths are relative to the importing HTML file.
affects: >=0.3.0
Errors
Common errors & fixes
Error: The service you have requested is not available yet.
Pug template compilation failed, often due to missing pug dependency.
fix
Run `npm install -D pug` to add the peer dependency.
TypeError: pugPlugin is not a function
Named import used instead of default import.
fix
Use `import pugPlugin from 'vite-plugin-pug'` (no curly braces).
[vite] Internal server error: Cannot find module 'vite-plugin-pug'
Plugin not installed or not in node_modules.
fix
Run `npm install -D vite-plugin-pug`.
Upgrade
Version history
0.4.1latest on npm
Audit
Dependencies
pugrequiredPug compiler required at runtime
Agent activity
17 hits · last 30 days
node
14
OpenAI (training)
1
Resources
vite-plugin-pug — npm install vite-plugin-pug · libregistry