entry

  • Type:
type Entry = Record<string, string | string[] | EntryDescription>;
  • Default:
const defaultEntry = {
  // default support for other suffixes such as ts, tsx, jsx, mjs, cjs
  index: 'src/index.js',
};

Used to set the entry modules for building.

The usage of source.entry is similar to the entry option in Rspack. The main difference is that Rsbuild will register html-webpack-plugin for each entry in source.entry to generate the corresponding HTML files.

  • Example:
export default {
  source: {
    entry: {
      foo: './src/pages/foo/index.ts',
      bar: './src/pages/bar/index.ts',
    },
  },
};

The generated directory structure is as follows:

.
├── foo.html
├── bar.html
└── static
    ├── css
    │   ├── foo.css
    │   └── bar.css
    └── js
        ├── foo.js
        └── bar.js

If you do not need to generate HTML files, you can set tools.htmlPlugin to false to disable this behavior.

Description Object

source.entry also supports Rspack's entry description object. For example:

export default {
  source: {
    entry: {
      foo: {
        import: './src/foo.js',
        runtime: 'foo',
      },
      bar: {
        import: './src/bar.js',
        runtime: 'bar',
      },
    },
  },
};

For the complete usage of the description object, please refer to Rspack - Entry Description Object.

ON THIS PAGE