改變目標(biāo)瀏覽器的自動(dòng)前綴

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"
]
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容