-
Notifications
You must be signed in to change notification settings - Fork 41
Adding ability to overwrite the default processFn method with a custom one. #58
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #58 +/- ##
==========================================
+ Coverage 93.85% 94.06% +0.20%
==========================================
Files 2 2
Lines 114 118 +4
Branches 22 22
==========================================
+ Hits 107 111 +4
Misses 6 6
Partials 1 1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! I like that you included the cheerio
object as well.
Awesome! Thanks! |
plugin.js
Outdated
@@ -18,6 +18,31 @@ try { | |||
} | |||
} | |||
|
|||
/** | |||
* The default function for adding the CSP to the head of a document | |||
* Can be overwritten to allow the developer can process the CSP in their own way |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Lil typo here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed!
Nice! Give the people what they want! One little nit, but otherwise looks good. +1 |
New option in additionalOpts to allow the developer to use the built CSP in any way they want to. `processFn` can either be defined on the CspHtmlWebpackPlugin, or in individual HtmlWebpackPlugin instances
…the full configuration is not needed to enable this plugin
bcc7022
to
b56efa7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙇
I've now merged this and bumped the npm package version - thanks for the reviews! |
Summary
This PR allows a developer to define a custom
processFn
method to overwrite the default behaviour of inlining the policy into the head of the document we're currently processing.Covers a request from #44, and an issue raised in #57
Implementation Details
defaultProcessFn
function, and made it the default behaviour so as to be backwards compatible.CspHtmlWebpackPlugin
additionalOpts
object, or from theHtmlWebpackPlugin
instancecspPlugin
object. This can allow for different processing functions perHtmlWebpackPlugin
instance