Change target browsers for Autoprefixer
改變目標(biāo)瀏覽器的自動(dòng)前綴
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.
當(dāng)前, CLI使用 Autoprefixer 來確定合適不同的瀏覽器和版本,你可以發(fā)現(xiàn)它必須指明特定的瀏覽器或不包括某個(gè)瀏覽器版本從你的構(gòu)建。
Internally, Autoprefixer relies on a library called Browserslist
to figure out which browsers to support with prefixing.
在內(nèi)部,自動(dòng)前綴依賴一個(gè)庫叫Browserslist 用來算出哪些瀏覽器支持前綴
There are a few ways to tell Autoprefixer what browsers to target:
這兒是一些方法告訴自動(dòng)前綴目標(biāo)瀏覽器:
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
增加一些文件到項(xiàng)目,目錄叫 .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.
自動(dòng)前綴將尋找要使用的配置文件或?qū)傩?,前綴是css. 檢出browserslist repo 為怎樣標(biāo)記特定瀏覽器或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項(xiàng)目將需要增加下列瀏覽器列表配置他們的package.json文件消除old flexbox前綴
package.json 配置:
"browserslist": [
"last 2 versions",
"not ie <= 10",
"not ie_mob <= 10"
]