jantimon / html-webpack-plugin

Simplifies creation of HTML files to serve your webpack bundles

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Webpack 4 Entrypoint undefined

ErikSchierboom opened this issue · comments

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

233

html-webpack-plugin 3.0.6

I have an same issue with you

The entry point is injected into webpack - what would be the correct way to give it a name?

Is this a Webpack issue then?

Does it produce any error or is this just a cosmetic issue?

It is just a cosmetic issue, so it is not really that important. It just might be confusing for new users.

If someone can find out how we can change it I would love to merge it into the plugin

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

its giving same error even when providing template and filename options .

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]

Same issue

webpack.config.js

...
plugins: [
      ...
      new HtmlWebPackPlugin({
        title: '...',
        template: path.resolve(folderSrc, 'index.html'),
        filename: 'index.html',
        hash: true
      })
    ]
...

Output

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

Env

node v9.7.1
npm 5.7.1
webpack 4.1.1
html-webpack-plugin 3.0.6
    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.

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

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:

new SingleEntryPlugin(this.context, template).apply(childCompiler);

The last one is the entrypoint name.

I'm just install and config html-loader. Then it working properly. So you can try

Fixed in 3.0.7

I updated the package to the latest version, but I do not know why it continues with "some" error and the script does not end, please help

Child html-webpack-plugin for "index.html":
1 asset
Entrypoint html-webpack-plugin for "index.html" = index.html
[0] (webpack)/buildin/module.js 519 bytes {0} [built]
[1] (webpack)/buildin/global.js 509 bytes {0} [built]
[3] ./node_modules/html-webpack-plugin/lib/loader.js!./src/assets/index.html 708 bytes {0} [built]
+ 1 hidden module
npm ERR! code ELIFECYCLE
npm ERR! errno 2

this is my log file:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\Program Files\nodejs\node.exe',
1 verbose cli 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'run-script',
1 verbose cli 'build' ]
2 info using npm@5.6.0
3 info using node@v8.9.4
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle reacttr@1.0.0prebuild: reacttr@1.0.0
6 info lifecycle reacttr@1.0.0
build: reacttr@1.0.0
7 verbose lifecycle reacttr@1.0.0build: unsafe-perm in lifecycle true
8 verbose lifecycle reacttr@1.0.0
build: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;E:\Apps\React\reacttr\node_modules.bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files\nodejs;C:\ProgramData\ComposerSetup\bin;C:\Program Files\Git\cmd;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\RailsInstaller\Git\cmd;C:\RailsInstaller\Ruby2.2.0\bin;C:\Users\Edgar Calderon\AppData\Local\Microsoft\WindowsApps;C:\Users\Edgar Calderon\AppData\Roaming\npm;C:\AppServ\Apache24\bin;C:\AppServ\php5;C:\AppServ\MySQL\bin;C:\Users\Edgar Calderon\AppData\Roaming\Composer\vendor\bin;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Users\Edgar Calderon\AppData\Local\atom\bin
9 verbose lifecycle reacttr@1.0.0build: CWD: E:\Apps\React\reacttr
10 silly lifecycle reacttr@1.0.0
build: Args: [ '/d /s /c', 'webpack --mode development --colors' ]
11 silly lifecycle reacttr@1.0.0build: Returned: code: 2 signal: null
12 info lifecycle reacttr@1.0.0
build: Failed to exec build script
13 verbose stack Error: reacttr@1.0.0 build: webpack --mode development --colors
13 verbose stack Exit status 2
13 verbose stack at EventEmitter. (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:285:16)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at EventEmitter.emit (events.js:214:7)
13 verbose stack at ChildProcess. (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at ChildProcess.emit (events.js:214:7)
13 verbose stack at maybeClose (internal/child_process.js:925:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid reacttr@1.0.0
15 verbose cwd E:\Apps\React\reacttr
16 verbose Windows_NT 10.0.16299
17 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "run-script" "build"
18 verbose node v8.9.4
19 verbose npm v5.6.0
20 error code ELIFECYCLE
21 error errno 2
22 error reacttr@1.0.0 build: webpack --mode development --colors
22 error Exit status 2
23 error Failed at the reacttr@1.0.0 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 2, true ]

Please report bugs here #900

Thanks for the fix @jantimon!

@ErikSchierboom please note that we will probably revert this change because of #900

The last version did not fix hmr for me. Html files doesn't update after compile.

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

Can you please try older versions and let me know which version works with HMR for you?

Same issue

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',
    })
  ]
}
commented

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",
}

Was also getting this error in addition to the entrypoint undefined one

screen shot 2018-04-05 at 10 54 07 am

Downgrading to 3.0.7 fixed the issue for me too.

We introduced a fix in 3.0.7 but removed it again in 3.0.8 because of many errors which were reported in #900

@jpike88 this is unrelated to the current issue could you please create a new issue?

sorry, moved onto fuse-box...

commented

@jantimon Bam! Guess that explains it. Thanks for the update. There should be something in the documentation that states the current problem, and the workaround. People will be spending several hours trying to fix a problem that it's not their own.

@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

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 here :(
v3.2.0

Same here!) Please do something!)

same issue.. need help....

Same issue here, v3.2.0

Same issue here, v3.2.0

Hope someone can fix #900 soon so this issue can be swiftly resolved.
I can't get through the build phase atm

commented

@jantimon Thanks for the response! I think everyone will come flocking around without actually reading the issue. Why not put it on the front of the README.md that it's a false positive?

it's not a meaningless log issue as the build fails...

@AhHa45 It does not cause the build to fail - it might be the last log message of webpack before your build fails.

If it really causes a build failure please open a bug report with a reproduction example.

Please see #895 (comment)