Configuring Browser Support
The official Nx plugins rely on browserslist for configuring application browser support. This affects builds, both production and development, and will decide on which transformations will be run on the code when built.
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.
By default, applications generated from official Nx generators ship an aggressively modern browser support config, in the form of a .browserslistrc
file in the root of the application with the following contents.
1last 1 Chrome version
2last 1 Firefox version
3last 2 Edge major versions
4last 2 Safari major version
5last 2 iOS major versions
6Firefox ESR
7not IE 9-11
8
This 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
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.
~/workspace❯
npx browserslist
1and_chr 61
2chrome 83
3edge 83
4edge 81
5firefox 78
6firefox 68
7ie 11
8ios_saf 13.4-13.5
9ios_saf 13.3
10ios_saf 13.2
11ios_saf 13.0-13.1
12ios_saf 12.2-12.4
13ios_saf 12.0-12.1
14safari 13.1
15safari 13
16safari 12.1
17safari 12
18
Alternatively, 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'