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 callbacks & full asset access #6

Closed
Xiphe opened this issue Feb 10, 2021 · 3 comments
Closed

Feature: Support callbacks & full asset access #6

Xiphe opened this issue Feb 10, 2021 · 3 comments
Assignees

Comments

@Xiphe
Copy link

Xiphe commented Feb 10, 2021

In order to skip assets based on data from other plugins (that are not available when configuring webpack)
I wold like to provide a callback instead of a pattern.

Currently due to the (pattern as RegExp).test(asset) i'm able to hack this by passing { constructor: { name: 'RegExp' }, test(asset) { /* my implementation */ } } as a pattern.

It would be really helpful to also get access on the full asset attributes in order to apply different filtering when it's a rel: 'preload' for example.

What I ideally would like to do is

type Asset = {
  tagName: string,
  closeTag: boolean,
  attributes: Record<string, string>
}
new HtmlWebpackPlugin({
  filename: join(OUTPUT_DIR, './dist/index.html'),
  excludeAssets: [(path: string, fullAsset: Asset): boolean => { /* my implementation */ }]
})

Same as #5: I'll happily provide PRs for this

@Xiphe Xiphe changed the title Support for callbacks on full asset Feature: Support callbacks & full asset access Feb 10, 2021
@swimmadude66
Copy link
Owner

I will take a stab at this tonight and push a new version if all works as expected. Thanks for raising this issue! Seems simple enough, and I will make sure to expose the full asset to the callback so you can use that in your tests.

@swimmadude66 swimmadude66 self-assigned this Feb 12, 2021
@swimmadude66
Copy link
Owner

Fixed in release v1.0.1

https:/swimmadude66/html-webpack-skip-assets-plugin/releases/tag/1.0.1

Thank you for bringing these to my attention!

@Xiphe
Copy link
Author

Xiphe commented Feb 13, 2021

Awesome! Thanks for taking my feedback in!

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

No branches or pull requests

2 participants