【问题标题】:Entrypoint undefined = ./index.html入口点未定义 = ./index.html
【发布时间】: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
    }
  };

这是我的项目结构

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

【问题讨论】:

  • 如果从HtmlWebPackPlugin 选项中完全删除filename 属性是否有效?
  • 那我应该在文件名的地方写什么呢??
  • 没关系,就是自动生成的html,webpack输出显示entrypoint=undefined是正常的。
  • 我从 web pack.config 文件中删除了 filename: "./index.html" 但仍然报同样的错误

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


【解决方案1】:

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

【讨论】:

  • 尝试删除这一行
  • 你只删除了filename ?
  • 我从 webpack.config 文件中删除了 filename: "./index.html" 但仍然报同样的错误
【解决方案2】:

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

【讨论】:

    猜你喜欢
    • 2019-01-31
    • 2018-11-23
    • 2022-01-24
    • 1970-01-01
    • 2020-12-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-24
    相关资源
    最近更新 更多