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

Fix the same chunkId is overwritten after using mini-css-extract-plugin #225

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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

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

2 participants