let pages = glob.sync(__dirname + '/source/pages/*.pug');
pages.forEach(function (file) {
let base = path.basename(file, '.pug');
pluginsOptions.push(
new HtmlWebpackPlugin({
filename: './' + base + '.html',
template: './pages/' + base + '.pug',
inject: true
})
)
});
..........
plugins: pluginsOptions