Registry / devops / nunjucks-webpack-plugin

nunjucks-webpack-plugin

JSON →
library5.0.0jsnpmunverified

A webpack plugin that compiles Nunjucks templates at build time. Version 5.0.0 (2018-11-12) supports webpack 2, 3, and 4, and drops Node.js 4. It renders .njk files with optional per-template context and writes outputs as webpack assets. Key differentiator: exposes webpack compilation hash (e.g., for cache busting) via __webpack__.hash in templates. Uses nunjucks ^3.0.0 as a peer dependency. Release cadence is low—last release was 2018; development appears inactive.

npm install nunjucks-webpack-plugin
INSTALL
IMPORT
SIG · NUNJUCKS-WEBPACK-P
N
nunjucks-webpack-plugin
devopsjavascriptv5.0.0
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 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

NunjucksWebpackPlugin
import NunjucksWebpackPlugin from 'nunjucks-webpack-plugin';
const NunjucksWebpackPlugin = require('nunjucks-webpack-plugin').default;
ESM default import. CommonJS users must use require('nunjucks-webpack-plugin').default.
default export
const NunjucksWebpackPlugin = require('nunjucks-webpack-plugin').default;
const NunjucksWebpackPlugin = require('nunjucks-webpack-plugin');
CommonJS require yields the default export; the module's export.default is the plugin constructor.

Basic setup: compile a single Nunjucks template to an HTML output file via webpack.

import NunjucksWebpackPlugin from 'nunjucks-webpack-plugin'; export default { plugins: [ new NunjucksWebpackPlugin({ templates: [ { from: 'src/template.njk', to: 'template.html' } ] }) ] };
Debug
Known issues
breakingOption `template` renamed to `templates` and must be an array. Single object no longer accepted.
fix
Use `templates: [{ from: ..., to: ... }]` instead of `template: { from: ..., to: ... }`.
affects: >=4.0.0
breakingOption `writeToFileWhenMemoryFs` renamed to `writeToFileEmit`.
fix
Use `writeToFileEmit: true` instead of `writeToFileWhenMemoryFs: true`.
affects: >=4.0.0
breakingDropped support for webpack 1.
fix
Upgrade to webpack 2, 3, or 4.
affects: >=4.0.0
breakingDropped support for Node.js 4.
fix
Use Node.js >= 6.9.0.
affects: >=5.0.0
gotchaIn v4+, all templates are always emitted as webpack assets. Output files are written to disk only when `writeToFileEmit` is true or when not using webpack-dev-server.
fix
Set `writeToFileEmit: true` per template to force writing to disk in memory-fs environments.
affects: >=4.0.0
deprecatedThe package has had no releases since 2018. It may not support webpack 5 or newer Nunjucks versions.
fix
Consider migrating to an actively maintained alternative (e.g., manually using nunjucks in a webpack loader).
affects: >=5.0.0
Errors
Common errors & fixes
Cannot find module 'nunjucks-webpack-plugin'
Missing installation of the plugin package.
fix
Run 'npm install --save-dev nunjucks-webpack-plugin'.
You must provide an array of templates
The `templates` option was passed as an object (single template) instead of an array.
fix
Wrap the template object in an array: `templates: [{ from: '...', to: '...' }]`.
Option `template` is not supported. Did you mean `templates`?
Using the old option name `template` (singular) instead of `templates` (plural).
fix
Rename `template` to `templates` and ensure it is an array.
Upgrade
Version history
5.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
nunjucks-webpack-plugin — npm install nunjucks-webpack-plugin · libregistry