Skip to content

Instantly share code, notes, and snippets.

@SudoCat
Last active May 6, 2017 13:49
Show Gist options
  • Save SudoCat/7c1323eeff1e83ed2a69b004b8c6024b to your computer and use it in GitHub Desktop.
Save SudoCat/7c1323eeff1e83ed2a69b004b8c6024b to your computer and use it in GitHub Desktop.
Nunjucks Loader Test Case
<!DOCTYPE html>
<html>
<head>
<title>{% block title %}layout{% endblock %}</title>
</head>
<body>
{% block content %}{% endblock %}
</body>
</html>
{% extends "layout.njk" %}
{% block title %}List of friends{% endblock %}
{% block content %}
<h2>List of friends</h2>
<ul>
<li>Freddy</li>
<li>Gerard</li>
<li>Gavin</li>
<li>Steven</li>
</ul>
{% endblock %}
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: './src/app.js',
output: {
filename: 'app.js',
path: path.resolve(__dirname, 'public/assets')
},
module: {
rules: [
{
test: /\.njk$/,
use: [
{
loader: 'nunjucks-isomorphic-loader',
query: {
root: [path.resolve(__dirname, 'src/views')]
}
}
]
}
]
},
plugins: [
new HtmlWebpackPlugin({
filename: 'list.html',
template: 'src/views/list.njk'
})
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment