create-react-app创建的package.json中的browserslist的意义是什么 [英] What is the significance of browserslist in package.json created by create-react-app

查看:753
本文介绍了create-react-app创建的package.json中的browserslist的意义是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一次采访中有人问我.我无法回答.

I was asked this in an interview. I could not answer.

"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]

我可以看到它是一个数组. "not ie&== 11"表示将无法在低于Internet Explorer v11的版本上运行 "op_mini"必须与Opera mini相关.

I can see that Its an array. "not ie <=11" means will not run on lower than Internet Explorer v11 "op_mini" must be related to Opera mini.

但是我想知道为什么需要它.

But I want to know why it is required.

推荐答案

这是一个React配置选项,用于了解构建过程应针对的浏览器.

That's a React configuration option to know which browsers the build process should target to.

如文档所述:

浏览器列表配置控制输出的JavaScript,以使发出的代码与指定的浏览器兼容.

The browserslist configuration controls the outputted JavaScript so that the emitted code will be compatible with the browsers specified.

如果要使用ES功能,请确保指定的所有浏览器都支持该功能,否则必须手动添加polyfills. React不会自动为您做到这一点.

If you are intend to use a ES feature make sure all browsers specified supports it, otherwise you have to include polyfills manually. React will not do it for you automatically.

有关更多信息,请参见: https://facebook.github. io/create-react-app/docs/supported-browsers-features

See more in: https://facebook.github.io/create-react-app/docs/supported-browsers-features

这篇关于create-react-app创建的package.json中的browserslist的意义是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆