Skip to content

Conversation

@msidolphin
Copy link

@msidolphin msidolphin commented Oct 12, 2023

Related issue

#216

Usage

Since mini-css-extract-plugin does not currently provide some hooks, developers can only inject their own integrity attributes via the insert function, I plan to inject integrity via the beforeTagInsert hook

new MiniCssExtractPlugin({
  // Options similar to the same options in webpackOptions.output
  // both options are optional
  filename: "[name].css",
  chunkFilename: "[id].css",
  insert: (link) => {
    link.integrity =
      __webpack_require__.sriHashes[chunkId + "_css/mini-extract"];
    document.head.appendChild(link);
  },
}),

Copy link
Collaborator

@jscheid jscheid left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution. Please could you add a test case that fails without the code changes? Tests still pass after I remove your change from examples/mini-css-extract-plugin/webpack.config.js.

@msidolphin
Copy link
Author

Thanks for your contribution. Please could you add a test case that fails without the code changes? Tests still pass after I remove your change from examples/mini-css-extract-plugin/webpack.config.js.

Ok, I'll remove this change and add additional unit tests

@s-elo
Copy link

s-elo commented Jun 17, 2025

@jscheid hi, any plan to merge this feature?

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.

3 participants