【发布时间】:2019-12-18 00:53:14
【问题描述】:
当我运行命令npm run build 时,我希望index.html 应该被复制到dist 中,就像本教程在10:00 一样:
https://www.youtube.com/watch?v=TzdEpgONurw&t=602s
但是什么也没发生,没有警告也没有错误。 这是配置:
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.export ={
mode: 'development',
module: {
rules: [
{
test: /.html$/,
use: [
{
loader: 'html-loader',
options: {minimize: true}
}
]
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: './src/index.html',
filename:'./index.html'
}),
],
}
【问题讨论】:
-
我花了一段时间才弄明白 :) 你在 webpack 中有错字
module.exports而不是module.export。还有一件事 -template: './src/index.html'和filename: index.html -
@GrzegorzT。哎呀,错字确实是问题所在,我会厌恶自己,即使在我浪费的几个小时内也没有弄清楚这一点:)
index.html没关系,它表示它将被复制到的目的地。
标签: webpack webpack-4 html-webpack-plugin