Change target browsers for Autoprefixer
改变目标浏览器的自动前缀
Currently, the CLI uses Autoprefixer to ensure compatibility
with different browser and browser versions. You may find it necessary to target specific browsers
or exclude certain browser versions from your build.
当前, CLI使用 Autoprefixer 来确定合适不同的浏览器和版本,你可以发现它必须指明特定的浏览器或不包括某个浏览器版本从你的构建。
Internally, Autoprefixer relies on a library called Browserslist
to figure out which browsers to support with prefixing.
在内部,自动前缀依赖一个库叫Browserslist 用来算出哪些浏览器支持前缀
There are a few ways to tell Autoprefixer what browsers to target:
这儿是一些方法告诉自动前缀目标浏览器:
Add a browserslist property to the package.json
file
增加浏览器列表的特征到 package.json
文件
"browserslist": [
"> 1%",
"last 2 versions"
]
Add a new file to the project directory called .browserslistrc
增加一些文件到项目,目录叫 .browserslistrc
### Supported Browsers
### 支持的浏览器
> 1%
last 2 versions
Autoprefixer will look for the configuration file/property to use when it prefixes your css.
Check out the browserslist repo for more examples of how to target
specific browsers and versions.
自动前缀将寻找要使用的配置文件或属性,前缀是css. 检出browserslist repo 为怎样标记特定浏览器或ban'j的更多例子。
Side note:
Those who are seeking to produce a progressive web app and are using Lighthouse to grade the project will
need to add the following browserslist config to their package.json file to eliminate the old flexbox prefixes
便笺:
那些试图制作progressive web app 和使用grade项目将需要增加下列浏览器列表配置他们的package.json文件消除old flexbox前缀
package.json
配置:
"browserslist": [
"last 2 versions",
"not ie <= 10",
"not ie_mob <= 10"
]