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

Error: ScriptExtHtmlWebpackPlugin: no asset with href #13

Closed
DevNebulae opened this issue Mar 20, 2017 · 18 comments
Closed

Error: ScriptExtHtmlWebpackPlugin: no asset with href #13

DevNebulae opened this issue Mar 20, 2017 · 18 comments

Comments

@DevNebulae
Copy link

Shouldn't the plugin be looking for something within its src tag?

It happened when I tried to inline a CoffeeScript source with the name animation.coffee, which gets transpiled to animation.js and in development mode, it will get renamed to animation.js?[hash]. Giving the file the async attribute works fine with the following regex: /animation\.*/. What goes wrong here?

@numical
Copy link
Owner

numical commented Mar 22, 2017

Sorry, I'm not following. The async functionality does work ..? What does not?
Perhaps you could post a working and a failing config so I better understand what you are asking?
Thanks!

@DevNebulae
Copy link
Author

Sorry, I was talking about the inline functionality. For some reason, the regex works with async, but not with inline.

@echenley
Copy link

echenley commented Apr 13, 2017

Also getting this error using the inline option.

Config is more or less:

entry: {
  // ...other bundles
  popout: path.resolve('src/popout/index.js')
}

plugins: [
  new HtmlWebpackPlugin({
    template: /* other */,
    chunks: ['bundle'],
    hash: true,
  }),
  new HtmlWebpackPlugin({
    template: path.resolve('src/popout/index.html'),
    filename: 'popout.html',
    chunks: ['popout'],
    hash: true,
  }),
  new ScriptExtHtmlWebpackPlugin({
    inline: 'popout',
    defaultAttribute: 'async',
  }),
]

May have something to do with using hash: true?

The error:

screen shot 2017-04-13 at 12 52 53 pm

@mbohgard
Copy link

mbohgard commented May 8, 2017

I have the same problem in one project where inline: 'manifest' fails with the same error as @echenley gets and in another one it works flawlessly, inlining the manifest code. Haven't been figured out why that is yet..

@numical
Copy link
Owner

numical commented May 10, 2017

@DevNebulae, @echenley
Sorry for the ridiculously long time to fix.
Probably too late for you but this is fixed on v1.7.2.

@numical
Copy link
Owner

numical commented May 10, 2017

@mbohgard - the issue fixed wass StyleExt not coping with the HtmlWebpack option hash.
Is your issue the same? I'll close this issue on the assumption it is but if not please just raise another.

@numical
Copy link
Owner

numical commented May 10, 2017

Closed as @mbohgard's issue assued to be the hash problem.

@numical numical closed this as completed May 10, 2017
@mbohgard
Copy link

@numical Thanks for giving this a shot. I don't use the hash option with HtmlWebpack since I use the chunkhash feature of Webpack itself. The "no asset with href" error still occurs with the new patch.

@numical
Copy link
Owner

numical commented May 14, 2017

@mbohgard - I'm not sure what your issue can be: chunkhash should be (!) supported. However I have put out a fix for someone else which might be related. Can you try the latest version 1.7.4? If that does not solve your problem, please raise a new issue with your webpack config detailed.

@definedw
Copy link

sorry to bother you,i got a same problem
is the reason of the problem that Because you set more than two of HtmlWebpackPlugin()?
01

02

03

@albv
Copy link

albv commented Jun 20, 2017

I've got the same error trying to inline webpack manifest. Here is minimal config to reproduce:

const path = require('path');

const root = path.join.bind(path, __dirname);
const CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin');


module.exports = function (options) {
  return {
    entry: {
      'main': './src/index.js'
    },

    resolve: {
      extensions: ['.js', '.json'],
      modules: [root('src'), root('node_modules')],
    },

    output: {
      path: root('dist'),
      filename: '[name].bundle.js',
      sourceMapFilename: '[file].map',
      chunkFilename: '[id].chunk.js'
    },
   
    plugins: [
      new CommonsChunkPlugin({
        name: ['manifest'],
        minChunks: Infinity,
      }),

      new ScriptExtHtmlWebpackPlugin({
        inline: [/manifest/]
      }),

      new HtmlWebpackPlugin({
        chunksSortMode: 'dependency',
        inject: true
      }),
    ]
  };
}

I found that it's order of plugins that matters. If I put ScriptExtHtmlWebpackPlugin after HtmlWebpackPlugin all works as expected.

....   
    plugins: [
      new CommonsChunkPlugin({
        name: ['manifest'],
        minChunks: Infinity,
      }),

      new HtmlWebpackPlugin({
        chunksSortMode: 'dependency',
        inject: true
      }),

      new ScriptExtHtmlWebpackPlugin({
        inline: [/manifest/]
      }),
    ]
....

@numical is it a bug?

@DevNebulae
Copy link
Author

@albv From brief scanning, people have used the configuration you are using, but triggered the bug somehow. So yes, I would say that it is a bug.

@zangcen
Copy link

zangcen commented Jun 21, 2017

if I set more than two of HtmlWebpackPlugin() , how to fixed this error ? @numical @definedw

@albv
Copy link

albv commented Jun 23, 2017

@zangcen try to put ScriptExtHtmlWebpackPlugin after the last of HtmlWebpackPlugin

@numical
Copy link
Owner

numical commented Jun 25, 2017

Hi All,
SciptExt must be after HtmlWebpackPlugin in the configuration - plugin order does matter in Webpack.

I will make the README more explicit on this issue - sorry to those who have wasted time with this.

With regards to using multiple instances of HtmlWebpackPlugin, this is not yet a scenario that ScriptExt has been designed or tested for. If this is something you would find useful please raise an issue defining what you need and suggesting how you think this is best configured. Better still, create a PR! :-)

For ideas, take a look at how the sister plugin style-ext-html-webpack-plugin copes with this scenario.

@albv
Copy link

albv commented Jun 25, 2017

One more thing that could give you the "no asset with href" error... If you are using output.publicPath option it must ends with /. So for example /static/ will work, /static won't.

@numical
Copy link
Owner

numical commented Jun 25, 2017

@albv - thanks! I had caught that on standard attributes but not resource hints. Fixed in v1.8.3.

@yorikworld
Copy link

Same here
publicPath: '/'
Error: Error: ScriptExtHtmlWebpackPlugin: no asset with href 'oembed.bundle.js'
plugin version: "script-ext-html-webpack-plugin": "^1.8.8"

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

8 participants