Skip to content

How to add multiple chunks/entries to a generated HTML page #2290

Answered by chenjiahan
mmazzarolo asked this question in Q&A
Discussion options

You must be logged in to vote

To add multiple entries in a single HTML page, it is recommended to use entry[].dependOn.

Rsbuild will support the following usage in the next release:

export default defineConfig({
  source: {
    entry: {
      index: {
        import: './src/index.js',
        // add pre.js to index.html
        dependOn: 'pre',
      },
      pre: './src/pre.js',
    },
  },
  tools: {
    bundlerChain(chain, { CHAIN_ID }) {
      // remove pre.html
      chain.plugins.delete(`${CHAIN_ID.PLUGIN.HTML}-pre`);
    },
  },
});

see: #2292

Note that we need to use bundlerChain to remove the generated pre.html, as Rsbuild currently does not provide configuration to remove specified HTML files.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@mmazzarolo
Comment options

Answer selected by mmazzarolo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants