jaketrent / html-webpack-template

a better default template for html-webpack-plugin
MIT License
830 stars 139 forks source link

Switch to using 'inject: true' and not duplicating upstream functionality #61

Closed edmorley closed 6 months ago

edmorley commented 6 years ago

The upstream html-webpack-plugin plugin used to include most logic in the actual template file, however in v2.29.0 switched to injecting the relevant markup into the template using JS (see https://github.com/jantimon/html-webpack-plugin/commit/c8a69255b9fd2f66a41457340629b738f2e18936).

Currently html-webpack-template must be used with that JS injection mode turned off (inject: false), since it instead re-implements much of the upstream functionality in the custom index.ejs.

This results in a few issues:

I would propose:

As an added bonus these changes will make it clearer what functionality this custom template adds, and then if in the future any of those features are upstreamed, this package can be simplified even further :-)

Thoughts? (If this sounds like something that would be accepted, I'm happy to open a PR.)

jaketrent commented 6 years ago

@edmorley thanks for outlining this. The situation and proposed direction are clear and helpful to me.

I love the idea of slimming this template and no duplicating upstream functionality. I know little about the fundamentals of what is broken and how changing inject true is going to fix it. Perhaps you could point me toward some basic education on the subject.

I'm in favor of moving in this direction and would welcome a PR.

jaketrent commented 6 years ago

Hey @edmorley I still like the idea of this -- not duplicating upstream functionality. I would welcome your expertise in adjusting it. Are you still interested? If not, no problem at all, and we can close this. What do you think?

edmorley commented 6 years ago

Hi! Sorry for the delayed reply. I'll try and take a look at a proof of concept PR this week :-)

merlinnot commented 6 years ago

Hi @edmorley , did you manage to take a look on this?

alex-shamshurin commented 6 years ago

Without inject = true this plugin break other plugins. I played some hours with it and realize that I can use it.

edmorley commented 5 years ago

Sorry for not having time to look at this. I believe it's something that's definitely worth doing, since in addition to the issues described in the OP, it caused breakage with this package when trying it with the new html-webpack-plugin v4 alpha. Those issues have since been fixed (html-webpack-plugin rolled back the breaking changes for now), however it proved how fragile inject: false is.

The Neutrino project has since switched away from using this package, so I probably won't have a chance to look at this - however happy to look over a PR if someone else does.

A first step to fixing this issue would be if someone could take a look at adding tests to this repository, that verified the output HTML for various combinations of options. Then when fixing this issue, it would be much easier to (a) review, (b) ensure no unexpected breakage.

alex-shamshurin commented 5 years ago

Right now I'm developing the same with handlebars engine and it will be possible to use it with "inject = true" and it much cleaner solution. All these "<% %>" impossible to read.

edmorley commented 5 years ago

A first step to fixing this issue would be if someone could take a look at adding tests to this repository,

I've filed #79 for this