rspack icon indicating copy to clipboard operation
rspack copied to clipboard

[Feature]: preload & prefetch plugin

Open weihongyu12 opened this issue 6 months ago • 1 comments

What problem does this feature solve?

I want to support resource hints in my project, such as preload/prefetch, to improve the performance of the production environment

What does the proposed API of configuration look like?

I tried to use @vue/preload-webpack-plugin, but it is not compatible. We can write a plugin, for example:

export default defineConfig({
  plugins: [
    new rspack.PreloadRspackPlugin({
      rel: 'preload',
      include: 'initial',
      fileBlacklist: [
        /\.map$/,
       /hot-update\.js$/,
      ],
    }),
    new rspack.PreloadRspackPlugin({
      rel: 'prefetch',
     include: 'asyncChunks'
    }),
]
});

Or migrate rsbuild's performance.preload and performance.prefetch :

export default defineConfig({
  performance: {
    dnsPrefetch: ['https://example.com'],
    preconnect: ['https://example.com/'],
    preload: {
      type: 'initial',
    },
    prefetch: {
      type: 'all-chunks',
    },
  },
});

weihongyu12 avatar Apr 19 '25 01:04 weihongyu12