Skip to content

[Feature]: preload & prefetch plugin #5411

@weihongyu12

Description

@weihongyu12

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',
    },
  },
});

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions