【发布时间】:2019-03-25 12:56:33
【问题描述】:
您好,我是 webpack 中一个相当新的程序员,我正在尝试使用 webpack 创建 React 应用程序。但我收到了这个错误。
错误
Child html-webpack-plugin for "index.html":
1 asset
Entrypoint undefined = ./index.html
webpack.config.js
[![const HtmlWebPackPlugin = require("html-webpack-plugin");
const path = require('path')
const htmlPlugin = new HtmlWebPackPlugin({
template: "./src/index.html",
filename: "./index.html"
});
module.exports = {
entry: "index.js",
output: {
path: path.resolve('dist'),
filename: 'bundle.js'
},
module: {
rules: \[
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
"presets": \["env", "react"\]
}
}
}
\]
},
plugins: \[htmlPlugin\],
devServer: {
contentBase: './dist',
hot: true
}
};
这是我的项目结构
【问题讨论】:
-
如果从
HtmlWebPackPlugin选项中完全删除filename属性是否有效? -
那我应该在文件名的地方写什么呢??
-
没关系,就是自动生成的html,webpack输出显示entrypoint=undefined是正常的。
-
我从 web pack.config 文件中删除了 filename: "./index.html" 但仍然报同样的错误
标签: reactjs webpack webpack-dev-server webpack-4