Builds that use browserslist, such as @nx/rspack web builds, read your application's browser support from it. It decides which transformations run on your code in both production and development builds.
Vite doesn't read browserslist. Set build.target in your Vite config instead.
In general, the more modern your applications browser support is, the smaller the filesize as the code can rely on modern API's being present and not have to ship polyfills or shimmed code.
Nx generators don't create a browserslist config. To add one, use either of these options:
- Create a
.browserslistrcfile in the project root. - Add a
browserslistkey to the project'spackage.json.
Browserslist also looks in parent directories, so a config in the workspace root applies to every project that doesn't have its own.
For example, the following .browserslistrc supports only recent browser versions.
last 1 Chrome versionlast 1 Firefox versionlast 2 Edge major versionslast 2 Safari major versionlast 2 iOS major versionsFirefox ESRnot IE 9-11This configuration is used for many tools including babel, autoprefixer, postcss, and more to decide which transforms are necessary on the source code when producing built code to run in the browser.
For additional information regarding the format and rule options, please see: https://github.com/browserslist/browserslist#queries
Debugging browser support
Section titled “Debugging browser support”Sometimes broad configurations like > 0.5%, not IE 11 can lead to surprising results, due to supporting browsers like Opera Mini or Android UC browser.
To see what browsers your configuration is supporting, run npx browserslist in the application's directory to get an output of browsers and versions to support.
chrome 154edge 154edge 153firefox 157firefox 153ios_saf 27.0ios_saf 26.6ios_saf 26.5ios_saf 26.4ios_saf 26.3ios_saf 26.2ios_saf 26.1ios_saf 26.0safari 27safari 26.6safari 26.5safari 26.4safari 26.3safari 26.2safari 26.1safari 26.0Alternatively, if your support config is short you can just add it as a string param on the CLI:
npx browserslist '> 0.5%, not IE 11'