{"id":20246,"library":"nunjucks-webpack-plugin","title":"nunjucks-webpack-plugin","description":"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.","status":"maintenance","version":"5.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/itgalaxy/nunjucks-webpack-plugin","tags":["javascript","webpack","webpack-plugin","plugin","nunjucks","nunj","template"],"install":[{"cmd":"npm install nunjucks-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add nunjucks-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add nunjucks-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM default import. CommonJS users must use require('nunjucks-webpack-plugin').default.","wrong":"const NunjucksWebpackPlugin = require('nunjucks-webpack-plugin').default;","symbol":"NunjucksWebpackPlugin","correct":"import NunjucksWebpackPlugin from 'nunjucks-webpack-plugin';"},{"note":"CommonJS require yields the default export; the module's export.default is the plugin constructor.","wrong":"const NunjucksWebpackPlugin = require('nunjucks-webpack-plugin');","symbol":"default export","correct":"const NunjucksWebpackPlugin = require('nunjucks-webpack-plugin').default;"}],"quickstart":{"code":"import NunjucksWebpackPlugin from 'nunjucks-webpack-plugin';\n\nexport default {\n  plugins: [\n    new NunjucksWebpackPlugin({\n      templates: [\n        { from: 'src/template.njk', to: 'template.html' }\n      ]\n    })\n  ]\n};","lang":"typescript","description":"Basic setup: compile a single Nunjucks template to an HTML output file via webpack."},"warnings":[{"fix":"Use `templates: [{ from: ..., to: ... }]` instead of `template: { from: ..., to: ... }`.","message":"Option `template` renamed to `templates` and must be an array. Single object no longer accepted.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Use `writeToFileEmit: true` instead of `writeToFileWhenMemoryFs: true`.","message":"Option `writeToFileWhenMemoryFs` renamed to `writeToFileEmit`.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Upgrade to webpack 2, 3, or 4.","message":"Dropped support for webpack 1.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Use Node.js >= 6.9.0.","message":"Dropped support for Node.js 4.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Set `writeToFileEmit: true` per template to force writing to disk in memory-fs environments.","message":"In 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.","severity":"gotcha","affected_versions":">=4.0.0"},{"fix":"Consider migrating to an actively maintained alternative (e.g., manually using nunjucks in a webpack loader).","message":"The package has had no releases since 2018. It may not support webpack 5 or newer Nunjucks versions.","severity":"deprecated","affected_versions":">=5.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'npm install --save-dev nunjucks-webpack-plugin'.","cause":"Missing installation of the plugin package.","error":"Cannot find module 'nunjucks-webpack-plugin'"},{"fix":"Wrap the template object in an array: `templates: [{ from: '...', to: '...' }]`.","cause":"The `templates` option was passed as an object (single template) instead of an array.","error":"You must provide an array of templates"},{"fix":"Rename `template` to `templates` and ensure it is an array.","cause":"Using the old option name `template` (singular) instead of `templates` (plural).","error":"Option `template` is not supported. Did you mean `templates`?"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}