Webpack 带有HTML网页包插件的Pug模板

Webpack 带有HTML网页包插件的Pug模板,webpack,html-webpack-plugin,pug-loader,Webpack,Html Webpack Plugin,Pug Loader,我目前正在尝试让帕格模板运行的。我按照他们的指示,能够使用定制的模板引擎,如车把或在我的情况下帕格。当我执行它时,我得到以下错误: ERROR in ./~/html-webpack-plugin/lib/loader.js!./src/index.pug Module build failed: Error: Cannot find module 'pug' 我当前的配置如下所示: const HtmlWebpackPlugin = require('html-webpack-plugin'

我目前正在尝试让帕格模板运行的。我按照他们的指示,能够使用定制的模板引擎,如车把或在我的情况下帕格。当我执行它时,我得到以下错误:

ERROR in ./~/html-webpack-plugin/lib/loader.js!./src/index.pug
Module build failed: Error: Cannot find module 'pug'
我当前的配置如下所示:

const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const path = require('path');

module.exports = {
    entry: {
        global: './src/assets/scripts/global.js',
        index: './src/assets/scripts/index.js',
    },
    output: {
        filename: '[name].bundle.js',
        path: path.resolve(__dirname, 'dist/js'),
        publicPath: '/assets/js/',
    },
    module: {
        rules: [
            {test: /\.pug$/, use: 'pug-loader'},
        ],
    },
    plugins: [
        new webpack.optimize.UglifyJsPlugin(),
        new HtmlWebpackPlugin({
            template: 'src/index.pug',
            filename: 'index.html',
            chunks: ['global', 'index'],
        }),
    ],
};

有什么建议吗?

我必须手动安装
pug
软件包本身。

你必须这样做。如果需要,可以添加块

new HtmlWebpackPlugin({
        filename: 'index.html',
        template: path.join(__dirname, './src/index.pug')
    });