output.overrideBrowserslist

  • Type: string[] | Record<RsbuildTarget, string[]
  • Default: undefined

Specifies the range of target browsers that the project is compatible with.

This value will be used by tools such as SWC and autoprefixer to identify the JavaScript syntax that need to be transformed and the CSS browser prefixes that need to be added.

Priority

The overrideBrowserslist config will override the .browserslistrc config file in the project and the browserslist field in package.json.

In most cases, it is recommended to use the .browserslistrc file rather than the overrideBrowserslist config. Because the .browserslistrc file is the official config file, it is more general and can be recognized by other libraries in the community.

For more details, see Browserslist.

Default Value

If there is no browserslist configs defined in the project, nor overrideBrowserslist defined, then Rsbuild will set the default browserslist to:

['chrome >= 87', 'edge >= 88', 'firefox >= 78', 'safari >= 14'];

Example

An example compatible with mobile scenarios:

export default {
  output: {
    overrideBrowserslist: [
      'iOS >= 9',
      'Android >= 4.4',
      'last 2 versions',
      '> 0.2%',
      'not dead',
    ],
  },
};

Check out the browserslist documentation to learn more about browserslist.

Set by Targets

When you build multiple targets at the same time, you can set different browser ranges for different targets. At this point, you need to set overrideBrowserslist to an object whose key is the corresponding build target.

For example to set different ranges for web and node:

export default {
  output: {
    overrideBrowserslist: {
      web: [
        'iOS >= 9',
        'Android >= 4.4',
        'last 2 versions',
        '> 0.2%',
        'not dead',
      ],
      node: ['node >= 20'],
    },
  },
};