-
-
Save SudoCat/7c1323eeff1e83ed2a69b004b8c6024b to your computer and use it in GitHub Desktop.
Nunjucks Loader Test Case
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>{% block title %}layout{% endblock %}</title> | |
</head> | |
<body> | |
{% block content %}{% endblock %} | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% 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 %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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