プラグイン html-webpack-plugin の設定に関する問題は次のとおりです。
プラグインでは、htmlplugin に n がありません。
別の状況はこれです
const path = require('path')
// 1.导入插件,得到构造函数
const HtmlPlugin = require('html-webpack-plugin')
// 2. 创建插件的实例对象
const HtmlPlugin = new HtmlPlugin({
template: './src/index.html',
filename: './index.html',
})
module.exports = {
mode: 'development',
//打包入口文件的路径
entry: path.join(__dirname, './src/index.js'),
output: {
//输出文件的存放路径
path: path.join(__dirname, './dist'),
// 输出文件的名称
filename: 'bundle.js',
},
// 挂载插件的实例对象
plugins: [HtmlPlugin]
}
2 つの名前が同じであるため、認識できなくなります。解決策は 2 つの名前のいずれかを変更することですが、以下のプラグインは上記のインスタンス オブジェクトと同じである必要があります。
サンプルコードは次のとおりです。
const path = require('path')
// 1.导入插件,得到构造函数
const HtmlPlugin = require('html-webpack-plugin')
// 2. 创建插件的实例对象
const htmlPlugin = new HtmlPlugin({
template: './src/index.html',
filename: './index.html',
})
module.exports = {
mode: 'development',
//打包入口文件的路径
entry: path.join(__dirname, './src/index.js'),
output: {
//输出文件的存放路径
path: path.join(__dirname, './dist'),
// 输出文件的名称
filename: 'bundle.js',
},
// 挂载插件的实例对象
plugins: [htmlPlugin]
}