html-webpack-plugin: Webpack 4 Entrypoint undefined

Description

When working with Webpack 4, people can now start with zero-configuration. This allows one to quickly get started with using Webpack, without any of the configuration hassle. Trying out Webpack 4, I tried to create a minimal configuration that uses the HtmlWebpackPlugin (see the Config section). While functionally working, I do get a warning about an undefined entrypoint.

While I can ignore this warning, I’m not sure if there actually is a problem or if there is something I can do about it. If there is something wrong in my configuration, it would be great if a message was printed that explains how to fix it.

I can reproduce this is in both development and production mode.

Error Message & Stack Trace

Entrypoint undefined = index.html

Config

Minimal version:

const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
    plugins: [new HtmlWebpackPlugin()]
};

More explicit version that also has the warning:

const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  entry: './src/index.js',
  output: {
    path: __dirname + '/dist',
    filename: 'bundle.js'
  },

  plugins: [new HtmlWebpackPlugin()]
};

Version with HTML loader that also has the warning:

const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  entry: './src/index.js',
  output: {
    path: __dirname + '/dist',
    filename: 'bundle.js'
  },
  module: {
    rules: [
      { test: /\.html$/i, loader: 'html-loader' },
    ]
  },

  plugins: [new HtmlWebpackPlugin()]
};

Environment

node -e "var os=require('os');console.log('Node.js ' + process.version + '\n' + os.platform() + ' ' + os.release())"
Node.js v8.9.3
win32 10.0.14393

npm --version
5.6.0

npm ls webpack
webpack@4.1.1

npm ls html-webpack-plugin
html-webpack-plugin@3.0.6

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 44
  • Comments: 42 (12 by maintainers)

Commits related to this issue

Most upvoted comments

Same issue.

plugins: [
        new HtmlWebpackPlugin({
            template: './src/index.html',
            …
Child html-webpack-plugin for "index.html":
     1 asset
    Entrypoint undefined = index.html
       [0] ./node_modules/html-webpack-plugin/lib/loader.js!./src/index.html 15.2 KiB {0} [built]

HMR not working for me in 3.1.0 and still entrypoint appears as undefined.

@superjose - actually it’s not an error just a meaningless log message 😃 So the workaround would be to ignore it (although I really don’t like that approach) I would be very happy for any help or idea how we or the webpack-dev-server team could fix #900 so we can apply the solution of 3.0.7 again

There seems to be a regression from 3.0.7 to 3.1.0. Installing 3.0.7 fixes the issue:

"devDependencies": {
    "html-webpack-plugin": "3.0.7",
}

sorry, moved onto fuse-box…

Do you perhaps know how the HtmlWebpackPlugin can ensure that Webpack does not specify the entrypoint as undefined? (see the discussion in this issue)

yep, provide all arguments to the SingleEntryPlugin constructor:

https://github.com/jantimon/html-webpack-plugin/blob/8131d8bb1dc9b185b3c1709264a3baf32ef799bc/lib/compiler.js#L50

The last one is the entrypoint name.

Same issue here, v3.2.0

same issue in v3.1.0 with webpack config below

...
const config = {
  mode: mode,
  entry: {
    index: './index.js'
  },
  context: projectPath,
  output: {
    filename: '[name].[chunkhash:22].js',
    chunkFilename: '[name].[chunkhash:22].js',
    path: buildPath
  },

  plugins: [
    new HTMLWebpackPlugin({
      template: 'index.html',
    })
  ]
}

same issue here 😦 v3.2.0

In the past it was a job for extract-text-webpack-plugin.

Unfortunately said plugin does not play well with webpack 4.

According to Michael Ciniawsky:

extract-text-webpack-plugin reached a point where maintaining it become too much of a burden and it’s not the first time upgrading a major webpack version was complicated and cumbersome due to issues with it

now i userd “mini-css-extract-plugin” is here to overcome those issues

Same issue here, v3.2.0

Same issue

Child html-webpack-plugin for “index.html”: 1 asset Entrypoint undefined = index.html

the same error is not cosmetic, since the script stops and the bundle does not end

    stats: {
        ...
        children: false, 
        ...
    },

Setting the property children to false will show off the log info. But I don’t know how to change it or solve it.

233

html-webpack-plugin 3.0.6

I have an same issue with you