Skip to content

Instantly share code, notes, and snippets.

@sethkrasnianski
Last active November 29, 2016 22:03
Show Gist options
  • Save sethkrasnianski/937cf9a961973ef59e72aa2f39620e67 to your computer and use it in GitHub Desktop.
Save sethkrasnianski/937cf9a961973ef59e72aa2f39620e67 to your computer and use it in GitHub Desktop.
Webpack static file goodness
const HtmlWebpackPlugin = require('html-webpack-plugin');
function buildPages(people) {
return [
new HtmlWebpackPlugin({
template: './templates/index.pug',
filename: 'index.html'
}),
new HtmlWebpackPlugin({
template: './templates/people.pug',
filename: 'people.html',
data: { people }
}),
...buildPeoplePages(people)
]
}
function buildPeoplePages(people) {
return people.map(({ name, title, bio, imagePath, _url }) => new HtmlWebpackPlugin({
title: name,
template: './templates/person.pug',
filename: `people/${name.toLowerCase().split(' ').join('-')}.html`,
data: { name, title, bio, imagePath, _url }
}))
}
module.exports = buildPages;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment