入口点未定义= ./index.html

时间:2019-03-25 12:56:33

标签: reactjs webpack webpack-dev-server webpack-4

嗨,我是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
    }
  };

这是我的项目结构

[https://i.stack.imgur.com/ve1oa.png]

2 个答案:

答案 0 :(得分:0)

也许filename: "./index.html"应该是filename: "index.html"吗? 或者只是将其删除

答案 1 :(得分:0)

似乎此错误消息是无害的,可以忽略:html-webpack-plugin issue #895