Html-webpack-plugin: WP4, Multiple Entry Points script injected in all files.

Created on 4 Mar 2018  路  8Comments  路  Source: jantimon/html-webpack-plugin

I am trying to separate entry points. This was ok with webpack 3.
I have 2 entry and expecting 2 different output.
Basically expecting login script injected to login page, index script injected to index page. No success yet.
screen shot 2018-03-04 at 05 53 23

This is the login html file. Network tab.
screen shot 2018-03-04 at 05 54 44

This is the index html file. Network tab.
screen shot 2018-03-04 at 05 55 19

I tried both repos. Same result.
webpack-contrib/html-webpack-plugin
jantimon/html-webpack-plugin

And webpack config for chunks. Tried thousand different setting here.
screen shot 2018-03-04 at 06 01 43

This is the html-webpack-plugin setup. Tried thousand different setting here, too.
screen shot 2018-03-04 at 06 03 08

Most helpful comment

In order to make splitting initial chunks and generating runtime chunk possible, I wrote this plugin: https://github.com/fenivana/html-webpack-include-sibling-chunks-plugin

All 8 comments

I finally made it work like this. Now all files injected in correct place.

splitChunks: {
 cacheGroups: {
   index: {
     name: "index",
     chunks: "async",
},
   login: {
     name: "login",
      chunks: "async",
},
}

In order to make splitting initial chunks and generating runtime chunk possible, I wrote this plugin: https://github.com/fenivana/html-webpack-include-sibling-chunks-plugin

I'm new to webpack , and I'm also trying to setup multiple entry-point , and webpack4 is the first version of webpack I've used.. so I thought that this plugin was not working for multiple-entry point, but now if you say
that in version 3 it worked, so probably It's a bug..
the problem is that OR I specify specific chunks and the application will include only those chunks but then I have to explicit the full dependency graph ( entrypoint + commonchunks that this entrypoint partecipated in ) , or if I specify none it will include all entrypoints and chunks in all instances of htmlwebpackplugin

so definitely both solutions are impossible to use...
(I think that this should be pointed as major bug for this plugin or at least specify in main readme that cannot be used with multiple entrypoint )

(@fenivana ) your plugin as patch to html-webpack-plugin works perfectly in my usecase :) thank you, anyway I still want to suggest to apply somehow the functionality of his plugin in html-webpack-plugin to avoid the necessity of having a plugin to patch another one.. :)

This issue involves a lot of refactoring as we need to switch to the webpack 4 api.
An entire refactoring will break this plugin for millions of people so we want wo be sure that the change is done well.
It will probably take about 5 days of work to get it done.
I am really thankful for your feedback but right now I am not able to get it fixed as fast as I wish I could.
Hopefully I鈥檒l get the opportunity to invest those five days soon. If you want to support this issue I am happy to help you get into the code or if you don鈥檛 want to invest your time but think it鈥檚 worth 5$ feel free to support the project on open collective..

Could you please try if this works for you with 4.x alpha?
Pull Request: #958

Npm pre release:

npm i html-webpack-plugin@next

@jantimon It is ok. Thanks.

@jantimon How is this meant to be used? I'm running into the same problem, and after installing the @next version of html-webpack-plugin, I'm trying to configure webpack.config.js to work this way but I'm having trouble.

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lonelyclick picture lonelyclick  路  3Comments

mmjamal picture mmjamal  路  3Comments

lcxfs1991 picture lcxfs1991  路  4Comments

NeverwinterMoon picture NeverwinterMoon  路  3Comments

amorphius picture amorphius  路  3Comments