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

feat: add beforeTagInsert hook #1054

Merged
merged 1 commit into from
Jan 31, 2024

Conversation

msidolphin
Copy link
Contributor

@msidolphin msidolphin commented Oct 7, 2023

This PR contains a:

  • bugfix
  • new feature
  • code refactor
  • test update
  • typo fix
  • metadata update

Motivation / Use-Case

Breaking Changes

Additional Info

When I tried webpack-subresource-integrity to inject integrities, I found that I couldn't add integrities to the style files if I also used mini-css-extract-plugin. due to the lack of hooks in mini-css-extract-plugin. Due to the lack of hooks in mini-css-extract-plugin, it is not possible to add additional attributes to the link tag.

Related issue

#40

Usage

import MiniCssExtractPlugin from 'mini-css-extract-plugin'

MiniCssExtractPlugin.getHooks(compiler).beforeTagInsert.tap(
  "YourPluginName",
  (source, varNames) =>
    compiler.webpack.Template.asString([
      source,
      `${varNames.tag}.setAttribute("integrity",  __webpack_require__.sriHashes[${varNames.chunkId}]);`,
    ])
);

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Oct 7, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: msidolphin / name: msidolphin (e295cc5)

src/index.js Outdated Show resolved Hide resolved
@alexander-akait
Copy link
Member

@msidolphin Also can you rebase, sorry for delay

@msidolphin
Copy link
Contributor Author

@msidolphin Also can you rebase, sorry for delay

The generated version of package-lock is too old, should I update it?

@alexander-akait
Copy link
Member

@msidolphin Just rebase

@msidolphin
Copy link
Contributor Author

@msidolphin Just rebase

Okay, I'm done.

@msidolphin msidolphin force-pushed the master branch 3 times, most recently from c4c6601 to 86cc2be Compare January 31, 2024 03:25
@alexander-akait
Copy link
Member

Thank you, I will do release after #1057

Copy link

codecov bot commented Jan 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (e3f8375) 90.40% compared to head (e295cc5) 90.31%.
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1054      +/-   ##
==========================================
- Coverage   90.40%   90.31%   -0.09%     
==========================================
  Files           5        6       +1     
  Lines         875      888      +13     
  Branches      256      259       +3     
==========================================
+ Hits          791      802      +11     
- Misses         74       76       +2     
  Partials       10       10              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@alexander-akait
Copy link
Member

I will fix errors in other PR, need more work

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.

2 participants