我使用webpack v4,我试图在webpack-dev-server中使用Pug,但是当我运行webpack-dev-server --mode development时,它并不提供编译后的Pug。拜托救救我。该怎么办呢。谢谢你的回复。这是我的配置:
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: './src/js/main.js',
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js'
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
},
{
test: /\.pug$/,
use: {
loader: 'pug-loader',
options: {
pretty: true
}
}
}
]
},
devServer: {
contentBase: path.join(__dirname, 'dist'),
hot: true,
open: true,
progress: true
},
plugins: [
new HtmlWebpackPlugin({
template: path.join(__dirname, 'src/templates/pages/index.pug'),
inject: false
})
]
};
发布于 2019-03-20 08:46:02
你好,您必须在HtmlWebpackPlugin上指定文件名,这样就可以从localhost:3000或localhost:3000/index.html为html提供服务。
devServer: {
...,
port: 3000
}
...
plugins: [
new HtmlWebpackPlugin({
template: path.join(__dirname, 'src/templates/pages/index.pug'),
filename: 'index.html'
})
]https://stackoverflow.com/questions/50276599
复制相似问题