A webpack plugin for nunjucks.
npm install --save-dev nunjucks-webpack-pluginimport NunjucksWebpackPlugin from "nunjucks-webpack-plugin";
export default {
plugins: [
new NunjucksWebpackPlugin({
templates: [
{
from: "/path/to/template.njk",
to: "template.html"
}
]
})
]
};It is possible to use multiple templates:
import NunjucksWebpackPlugin from "nunjucks-webpack-plugin";
export default {
plugins: [
new NunjucksWebpackPlugin({
templates: [
{
from: "/path/to/template.njk",
to: "template.html"
},
{
from: "/path/to/next-template.njk",
to: "next-template.html"
}
]
})
]
};-
templates- (require)arraylist of templates.-
from- (require)stringpath to template. -
to- (require)stringdestination path include filename and extension (relativeoutputwebpack option). -
context- (optional) instead globalcontext(see above), see render second argument. The following webpack compilation variables are also sent through to the template under the__webpack__object:- hash
-
callback- (optional) instead globalcallback(see above), see render third argument. -
writeToFileEmit- (optional, default: false) - If set totruewill emit to build folder and memory in combination withwebpack-dev-server
-
-
configure- (optional)objectornunjucks.Environmentsee configure options.
Feel free to push your code if you agree with publishing under the MIT license.