Last active
November 29, 2016 22:03
-
-
Save sethkrasnianski/937cf9a961973ef59e72aa2f39620e67 to your computer and use it in GitHub Desktop.
Webpack static file goodness
This file contains hidden or 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
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