https://github.com/itgalaxy/nunjucks-webpack-plugin
A webpack plugin for nunjucks.
https://github.com/itgalaxy/nunjucks-webpack-plugin
nunjucks webpack webpack-plugin
Last synced: 8 months ago
JSON representation
A webpack plugin for nunjucks.
- Host: GitHub
- URL: https://github.com/itgalaxy/nunjucks-webpack-plugin
- Owner: itgalaxy
- License: mit
- Created: 2017-04-06T12:40:05.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2021-07-15T14:12:09.000Z (almost 5 years ago)
- Last Synced: 2024-10-29T21:10:17.991Z (over 1 year ago)
- Topics: nunjucks, webpack, webpack-plugin
- Language: JavaScript
- Size: 299 KB
- Stars: 27
- Watchers: 7
- Forks: 12
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# nunjucks-webpack-plugin
[](https://www.npmjs.org/package/nunjucks-webpack-plugin)
[](https://travis-ci.org/itgalaxy/nunjucks-webpack-plugin)
[](https://david-dm.org/itgalaxy/nunjucks-webpack-plugin?type=dev)
[](https://david-dm.org/itgalaxy/nunjucks-webpack-plugin?type=peer)
[](https://greenkeeper.io)
A webpack plugin for nunjucks.
## Install
```shell
npm install --save-dev nunjucks-webpack-plugin
```
## Usage
```js
import 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:
```js
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"
}
]
})
]
};
```
## Options
* `templates` - (require) `array` list of templates.
* `from` - (require) `string` path to template.
* `to` - (require) `string` destination path include filename and extension
(relative `output` webpack option).
* `context` - (optional) instead global `context` (see above), see
[render](https://mozilla.github.io/nunjucks/api.html#render) second
argument. The following webpack compilation variables are also sent
through to the template under the `__webpack__` object:
* hash
* `callback` - (optional) instead global `callback` (see above), see
[render](https://mozilla.github.io/nunjucks/api.html#render) third argument.
* `writeToFileEmit` - (optional, default: false) - If set to `true` will emit
to build folder and memory in combination with `webpack-dev-server`
* `configure` - (optional) `object` or `nunjucks.Environment` see
[configure](https://mozilla.github.io/nunjucks/api.html#configure) options.
## Contribution
Feel free to push your code if you agree with publishing under the MIT license.
## [Changelog](CHANGELOG.md)
## [License](LICENSE)