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
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
pug-plain-loader (webpack loader)
✓ module.exports = { module: { rules: [ { test: /\.pug$/, loader: 'pug-plain-loader' } ] } }
✗ import pugPlainLoader from 'pug-plain-loader'
This package is a webpack loader, not a JavaScript module. Configure it in webpack.config.js under module.rules.
pug-plain-loader + raw-loader
✓ module.exports = { module: { rules: [ { test: /\.pug$/, oneOf: [ { exclude: /\.vue$/, use: ['raw-loader', 'pug-plain-loader'] }, { use: ['pug-plain-loader'] } ] } ] } }
✗ module.exports = { module: { rules: [ { test: /\.pug$/, use: ['raw-loader', 'pug-plain-loader'] } ] } }
Using raw-loader with pug-plain-loader on Vue component templates will break. Use oneOf to exclude .vue files from the raw-loader chain.
data option
✓ module.exports = { module: { rules: [ { test: /\.pug$/, loader: 'pug-plain-loader', options: { data: { myVar: 'value' } } } ] } }
✗ module.exports = { module: { rules: [ { test: /\.pug$/, loader: 'pug-plain-loader', options: { data: 'value' } } ] } }
The data option must be an object containing locals passed to the template. It is typically not recommended when using with Vue components.
Shows installation, webpack configuration for Vue single-file components, and a basic Pug template in a .vue file.
// Install: npm install -D pug-plain-loader pug
// webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.pug$/,
loader: 'pug-plain-loader'
}
]
}
};
// App.vue (Vue single-file component)
<template lang="pug">
div
h1 Hello World
p This is a Pug template inside a Vue component.
</template>
<script>
export default {
name: 'App'
}
</script>
Errors
Common errors & fixes
Module not found: Error: Can't resolve 'pug'
pug is a peer dependency and not installed.
Module build failed (from ./node_modules/pug-plain-loader/index.js):
Error: Cannot find module 'pug'
Same as above - missing pug peer dependency.
Audit
Dependencies
pugrequiredpeer dependency - the Pug compiler is required at runtime