You can use different template engines by specifying the loader in the template option or by configuring Webpack rules for specific file extensions.
Option 1: Inline loader specification
Use the loader!template syntax. Note: Do not use this if you already have a global rule for that file type, as Webpack may attempt to apply the loader twice.
new HtmlWebpackPlugin({
template: "pug-loader!template.pug",
})
Option 2: Webpack rules (Recommended)
Configure Webpack to handle the file extension globally, then simply point the plugin to the file.
module.exports = {
module: {
rules: [{ test: /\.pug$/, loader: "pug-loader" }],
},
plugins: [
new HtmlWebpackPlugin({
template: "template.pug",
}),
],
};