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

Support custom value callback #44

Closed
devpreview opened this issue Mar 16, 2018 · 4 comments
Closed

Support custom value callback #44

devpreview opened this issue Mar 16, 2018 · 4 comments

Comments

@devpreview
Copy link

For example:

new ScriptExtHtmlWebpackPlugin({
  custom: [
    {
      test: /\.js$/,
      attribute: 'onload',
      value: (entry) => {return 'alert("loaded ' + entry + '");'}
     }
   ]
}),
@numical
Copy link
Owner

numical commented Mar 17, 2018

Can you explain the use case?
When is the function called and what is passed to it?

@lili21
Copy link

lili21 commented Jul 23, 2018

I think it would be useful for things like tracking the resources which load failed.

new ScriptExtHtmlWebpackPlugin({
  custom: [
    {
      test: /\.js$/,
      attribute: 'onerror',
      value: e => { // track the resource }
     }
   ]
}),

@numical
Copy link
Owner

numical commented Oct 29, 2018

Sorry - still not clear on when the function wuld be called and hat data would be passed.
Happy to re-open if more clarity available - or better a spike-PR! :-)

@numical numical closed this as completed Oct 29, 2018
@ykxkknd2
Copy link

ykxkknd2 commented Apr 28, 2019

@numical I need this too. For example, When the resource requested fails, and the error event is reported to the log.The callback parameter is the filename. Like this

new ScriptExtHtmlWebpackPlugin({
  custom: [
    {
      test: /\.js$/,
      attribute: 'onerror',
      value: filename => report(filename)
     }
   ]
}),

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

4 participants