Nunjucks loader for Webpack.
npm install super-nunjucks-loaderNunjucks loader for Webpack.
```
npm install --save super-nunjucks-loader
And in your Webpack configuration:
`${__dirname}/src/
module.exports = {
// ...
module: {
rules: [
{
test: /\.html/,
exclude: /(node_modules)/,
use: ['super-nunjucks-loader'],
options: {
globals: {
PRODUCTION: process.env.NODE_ENV === 'production'
},
options: {
noCache: true
},
path: `
}
}
]
}
// ...
};
#### Options
| Name | Description |
|---------|--------------------------------------------------|
| context | Object of variables to pass as Nunjucks context. |
| globals | Variables to add to Nunjucks global scope. |
| options | Options passed into Nunjucks.configure. |
| path | Directory for Nunjucks to find templates. |
Then require:
```
const htmlString = require('./index.html');