Skip to content

fix function getScriptName in element.js #19

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

Closed
koalaink opened this issue May 12, 2017 · 2 comments
Closed

fix function getScriptName in element.js #19

koalaink opened this issue May 12, 2017 · 2 comments

Comments

@koalaink
Copy link

koalaink commented May 12, 2017

webpack config

{
...
plugins:[
  new webpack.optimize.CommonsChunkPlugin({
      name: [`${project.projectName}/js/vendor`, `${project.projectName}/js/manifest`],
      minChunks: Infinity,
      filename: `[name].[chunkhash:8].js`,
    }),
  new ScriptExtHtmlWebpackPlugin({
      inline: 'manifest'
    }),
]

Error: ScriptExtHtmlWebpackPlugin: no asset with href 'manifest.d41d8cd9.js'

modify function getScriptName as bellow, it works well

const getScriptName = (options, tag, compilation) => {
  let scriptName = getRawScriptName(tag);
  // remove publicPath prefix
  // if (scriptName.includes('/')) {
  //   scriptName = scriptName.replace(CONSTANTS.PUBLIC_PATH_PREFIX, '');
  // }
  scriptName = scriptName.replace(compilation.outputOptions.publicPath, '');
  if (options.htmlWebpackOptions.hash) {
    scriptName = scriptName.split('?', 1)[0];
  }
  return scriptName;
};
@numical
Copy link
Owner

numical commented May 14, 2017

Hi,
I could not repeat your issue - I suspected either the chunkhash or the mutliple '/'s in the path, but neither seemed to break ScriptExt.
However your suggested change was a good one so I included it in a refactor for v1.7.4. Could you try out v1.7.4 to see if it fixes your issue. I will assume so as it is your suggesed fix (!) but do let me know if not.

@numical numical closed this as completed May 14, 2017
@koalaink
Copy link
Author

My issue is fixed with v1.8.0. thx

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