preload-webpack-plugin icon indicating copy to clipboard operation
preload-webpack-plugin copied to clipboard

preload not worked as expected

Open tr1s opened this issue 6 years ago • 1 comments

I'm using the beta, so that fixed my cb is not a function problem, but now nothing will append.

I've tried putting it after the HtmlWebpackPlugin and after the ScriptExtHtmlWebpackPlugin plugins and neither worked. I also tried

plugins: [
  new HtmlWebpackPlugin(),
  new PreloadWebpackPlugin({
    rel: 'preload',
    as(entry) {
      if (/\.css$/.test(entry)) return 'style';
      if (/\.woff$/.test(entry)) return 'font';
      if (/\.png$/.test(entry)) return 'image';
      return 'script';
    }
  })
]

as well as...

plugins: [
  new HtmlWebpackPlugin(),
  new PreloadWebpackPlugin()
]

but nothing seems to work.

@timothyvanderaerden you helped me before with the beta issue. Is there any chance you can test my webpack-boilerplate and see if it's working for you? or perhaps see what I'm doing wrong?

Thank you, let me know. I'd like to get this working for my CSS file and woff2/woff links that are being injected.

tr1s avatar Jan 29 '19 23:01 tr1s

This is more of a question then a bug which is discussed here: #55. I opened a pull request in your project with the suggested changes.

For reference to anyone landing on this thread, if you want to use preload for something that is resolved using file-loader. You should include allAssets.

    new PreloadWebpackPlugin({
      rel: 'preload',
      include: 'allAssets'
    }),

timothyvanderaerden avatar Jan 30 '19 19:01 timothyvanderaerden