gpt4 book ai didi

webpack - 带有 HTML Webpack 插件的 Pug 模板

转载 作者:行者123 更新时间:2023-12-04 02:04:29 27 4
gpt4 key购买 nike

我目前正在尝试使用 HTML Webpack Plugin 运行 Pug 模板.我按照他们的指示能够使用自定义模板引擎,如 Handlebars 或在我的情况下 Pug。当我执行它时,我收到此错误:

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包装本身。

关于webpack - 带有 HTML Webpack 插件的 Pug 模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44565379/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com