Skip to content

Commit 6f8d5f5

Browse files
author
evilebottnawi
committed
Feature: adds ability to pass configure as nunjucks.Environment.
1 parent 011ed56 commit 6f8d5f5

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](http://semver.org).
66

77
## Head
88

9+
* Feature: adds ability to pass `configure` as `nunjucks.Environment`.
910
* Fixed: all errors are sent into `compilation.errors` now.
1011
* Fixed: use `fs-extra` to output file when `writeToFileEmit: true`.
1112
* Changed: rename option from `writeToFileWhenMemoryFs` to `writeToFileEmit`.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export default {
7575
* `writeToFileEmit` - (optional, default: false) - If set to `true` will emit
7676
to build folder and memory in combination with `webpack-dev-server`
7777

78-
* `configure` - (optional) see
78+
* `configure` - (optional) `object` or `nunjucks.Environment` see
7979
[configure](https://mozilla.github.io/nunjucks/api.html#configure) options.
8080

8181
## Contribution

src/NunjucksWebpackPlugin.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,13 @@ class NunjucksWebpackPlugin {
4040
}
4141

4242
compiler.plugin("emit", (compilation, callback) => {
43-
nunjucks.configure(
44-
this.options.configure.path,
45-
this.options.configure.options
46-
);
43+
const configure =
44+
this.options.configure instanceof nunjucks.Environment
45+
? this.options.configure
46+
: nunjucks.configure(
47+
this.options.configure.path,
48+
this.options.configure.options
49+
);
4750

4851
const promises = [];
4952

@@ -60,7 +63,7 @@ class NunjucksWebpackPlugin {
6063
fileDependencies.push(template.from);
6164
}
6265

63-
const res = nunjucks.render(
66+
const res = configure.render(
6467
template.from,
6568
template.context ? template.context : null,
6669
template.callback ? template.callback : null

0 commit comments

Comments
 (0)