Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Support html-webpack-plugin 4.x #16

Closed
wants to merge 6 commits into from
Closed

[Feature] Support html-webpack-plugin 4.x #16

wants to merge 6 commits into from

Conversation

sibiraj-s
Copy link
Contributor

@sibiraj-s sibiraj-s commented Sep 20, 2018

Summary

Support html-webpack-plugin-4.x

Requirements

Closes #20

@sibiraj-s sibiraj-s changed the title feat: suppot html-webpack-plugin 4.x [Feature] Suppot html-webpack-plugin 4.x Sep 20, 2018
Copy link
Contributor

@AnujRNair AnujRNair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @sibiraj-s, thanks for the PR!
Some comments below :)

package.json Outdated
@@ -31,7 +31,7 @@
},
"peerDependencies": {
"webpack": "^2 || ^3 || ^4",
"html-webpack-plugin": "^2 || ^3"
"html-webpack-plugin": "^2 || ^3 || ^4.0.0-alpah.2"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small sp mistake here: alpha

We'll probably wait for the major version to drop before merging this just incase the API changes, so let's also update this simply to ^4

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😅 Will Update.

plugin.js Show resolved Hide resolved
@AnujRNair
Copy link
Contributor

Eventually we will remove them, but that would require a major bump - the more backward compatibility we can keep, the less we break this plugin for anyone else who might be using it at the moment

@AnujRNair
Copy link
Contributor

I'll mark this as Ready to Merge, but won't actually merge until HTMLWebpackPlugin comes out of alpha and beta, just incase there are unforseen API updates

Thanks for the contribution!

@sibiraj-s sibiraj-s changed the title [Feature] Suppot html-webpack-plugin 4.x [Feature] Support html-webpack-plugin 4.x Sep 20, 2018
@codecov
Copy link

codecov bot commented Sep 21, 2018

Codecov Report

Merging #16 into master will decrease coverage by 1.16%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #16      +/-   ##
==========================================
- Coverage   98.79%   97.63%   -1.17%     
==========================================
  Files           2        2              
  Lines         166      169       +3     
  Branches        9       10       +1     
==========================================
+ Hits          164      165       +1     
- Misses          2        4       +2
Impacted Files Coverage Δ
plugin.js 93.84% <50%> (-2.93%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b0adaea...3232f4d. Read the comment docs.

@sibiraj-s
Copy link
Contributor Author

sibiraj-s commented Sep 28, 2018

Updated html-webpack-plugin to beta.

@Saravanan90
Copy link

@AnujRNair FYR jantimon/html-webpack-plugin#953 (comment)

@Saravanan90
Copy link

@AnujRNair Any ETA on merging this PR

@AnujRNair
Copy link
Contributor

@sibiraj-s do you mind making the dependency ^ 4? Then I'll merge and release this so it's ready for when html-webpack-plugin@4 is released - it will also mean that devs can start using your changes now

@sibiraj-s
Copy link
Contributor Author

done 👍

@phil-lgr
Copy link

phil-lgr commented Dec 6, 2018

Hey I just tried the version on this branch, works super for me!

one thing:

processCsp(htmlPluginData, compileCb) {
        const $ = cheerio.load(htmlPluginData.html, {
            decodeEntities: false
        });

        let metaTag = $('meta[http-equiv="Content-Security-Policy"]');

        // if not enabled, remove the empty tag
        if (!this.isEnabled(htmlPluginData)) {
            // HERE <-----------------------  better to just bail out and call callback
            return compileCb(null, htmlPluginData);
        }

otherwise

htmlPluginData.html = $.html();

will insert

<html><head></head><body></body></html> to the template!

@phil-lgr
Copy link

phil-lgr commented Dec 6, 2018

basically if disableCspPlugin: true I would not touch the template at all

@AnujRNair
Copy link
Contributor

Hi @phil-lgr!

We added this line as some templates had empty CSP meta tags which we wanted to remove if the dev marked the plugin as disabled - we should expand this to check whether anything was actually removed or not - if so, return the new HTML, and if not, bail the plugin

Would you be willing to make a PR for this change?

@phil-lgr
Copy link

phil-lgr commented Dec 7, 2018

Hello!

I think it makes things more complicated:

We added this line as some templates had empty CSP meta tags which we wanted to remove if the dev marked the plugin as disabled

IMO if the plugin is disabled it should not touch the template at all. Removing an empty CSP policy when disableCspPlugin: true is confusing, disable should means don't touch my template no nothing.

People use html-plugin for other scenario than producing an index.html

I use it to create my manifest.json:

image

so I just want to stress that I need disableCspPlugin: true to not touch the template at all.

if you are ok with the above, I'll create a PR! 👍

@phil-lgr
Copy link

phil-lgr commented Dec 7, 2018

we can create another option, maybe cleanEmptyCsp: true | false if you want?

@AnujRNair AnujRNair mentioned this pull request Dec 19, 2018
4 tasks
@AnujRNair
Copy link
Contributor

I've merged html webpack plugin 4 support in this PR: #23 to avoid going back and forth over merge conflicts :) Thanks for adding this in for us!

@AnujRNair AnujRNair closed this Dec 19, 2018
@phil-lgr
Copy link

Hi, I'd appreciate if you could reply to: #16 (comment)

Again, disableCspPlugin: true should not do anything to the template

we need to remove htmlPluginData.html = $.html(); when disabling!

@AnujRNair
Copy link
Contributor

Hi @phil-lgr - sorry for the delayed response!

I agree - this is an unfortunate side effect of simply including the plugin in your webpack config at the moment, and should change. I'll shortly be looking into how we can disable the plugin in a safe manner whilst still keeping backwards compatibility with the existing setup.

Otherwise I will be shortly adding more features into the plugin which will require a major version bump, and I'll change the behaviour of the setting then

Thanks!

@phil-lgr
Copy link

no worries, still appreciate the work done here

ok, I'll keep an eye on that update then, thanks

@AnujRNair
Copy link
Contributor

@phil-lgr are you able to provide me with a minimal sample repo reproducing the issue you're seeing? The webpack config and the HtmlWebpackPlugin template file you're using to create your manifest would be extremely beneficial
Thanks!

@phil-lgr
Copy link

phil-lgr commented Dec 20, 2018 via email

@sibiraj-s
Copy link
Contributor Author

I suggest to open a new issue and track it separately, @phil-lgr If you think it is a bug or something else.

The discussion is out of topic to this PR

cc @AnujRNair

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants