请帮忙。我尝试在我的项目中使用 pug-html-loader。你们能帮我找到解决方案吗?我的哈巴狗文件在文件夹“/app/views”中,我喜欢生成 html 文件。如果您找到解决方案,我将非常有帮助。
错误信息:
- Module not found: Error: Can't resolve 'pug-html-loader' in 'C:\xampp\htdocs\pug-boilerplate'
- ModuleNotFoundError: Module not found: Error: Can't resolve 'pug-html-loader' in 'C:\xampp\htdocs\pug-boilerplate'
我的 webpack.config 是:
const path = require('path')
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const IS_DEVELOPMENT = process.env.NODE_ENV === 'dev'
const dirApp = path.join(__dirname, 'app')
const dirViewPages = path.join(__dirname, '/views')
const dirNode = 'node_modules'
module.exports = {
entry: [
path.join(dirApp, 'index.js'),
path.join(dirStyles, 'index.scss')
],
output: {
path: path.resolve(__dirname, '/public'),
filename: '[name].bundle.js'
},
resolve: {
modules: [
dirApp,
dirNode,
dirViewPages
]
},
plugins: [
new webpack.DefinePlugin({
IS_DEVELOPMENT
}),
new HtmlWebpackPlugin({
filename: 'gastro.html',
template: `${dirViewPages}/pages/gastro.pug`,
inject: false
}),
new HtmlWebpackPlugin({
filename: 'index.html',
template: `${dirViewPages}/base.pug`,
inject: false
})
],
module: {
rules: [
{
test: /\.pug/,
use: ['html-loader?attrs=false', 'pug-html-loader',
{
loader: 'pug-html-loader',
options: {
pretty: true
}
}]
},
]
},
}