当前位置:网站首页>Vite2 is compatible with lower versions of chrome (such as Sogou 80). Some grammars requiring higher versions are processed through polyfills
Vite2 is compatible with lower versions of chrome (such as Sogou 80). Some grammars requiring higher versions are processed through polyfills
2022-06-30 21:55:00 【Program W】
Preliminary treatment
- Introduce plug-ins to handle compatibility issues
npm install @vitejs/plugin-legacy -D
- To configure
vite.config.js targets: The default ispackage.jsonMediumbrowserslistSuggested valueadditionalLegacyPolyfillspolyfillsmodernPolyfills: Enabling this option will generate a separate for the new buildpolyfillsblock , The official does not recommend the use of , Because of its automatic detection , After the configuration , Instant browser support , Still usenomoduleLoadingpolyfillsScript for ( I am herereplaceAll()Configure inpolyfills, Don't take effect , Estimate the cutting-edge function of calculation , So either change the wording , Or it has to be here )
import legacy from '@vitejs/plugin-legacy'
plugins: [
vue(),
vueSetupExtend(),
AutoImport({
imports: ['vue', 'vue-router', 'vuex'],
}),
legacy({
// Try to be compatible with older browsers ( barring ie11)
targets: ['chrome 80'],
additionalLegacyPolyfills: ['regenerator-runtime/runtime'] // Configured pair ie11 It's no use
})
]
After the configuration , Different scripts will be loaded dynamically according to the browser support ,
<script nomodule>This machine is not supported ESM Load conditionally in the browser ofpolyfillsAnd old bundles .
Problem location ( Grammar problem )
viteAfter packing, it's stilles6grammar , Some grammars require a higher version , Need to pass throughpolyfills(polyfillsBy simulating equivalent code in a lower version of the browser , To implement the behavior of high version syntax ) To deal with
replaceAll ()Supported at leastchrome85
TypeError: wye(...).replaceAll is not a function
Compatible Syntax
polyfillCannot be used directly , Need to be inplugin-legacyUse in ,
legacy({
targets: ['chrome 80', 'ie >= 11'],
additionalLegacyPolyfills: ['regenerator-runtime/runtime'], // regenerator-runtime/runtime @dian/polyfill
renderLegacyChunks: true,
polyfills: [
'es.symbol',
'es.array.filter',
'es.promise',
'es.promise.finally',
'es/map',
'es/set',
'es.array.for-each',
'es.object.define-properties',
'es.object.define-property',
'es.object.get-own-property-descriptor',
'es.object.get-own-property-descriptors',
'es.object.keys',
'es.object.to-string',
'web.dom-collections.for-each',
'esnext.global-this',
'esnext.string.match-all',
// This cannot be handled
'es.string.replace-all'
]
})
- in
modernPolyfills( Handle... Successfully )
legacy({
targets: ['chrome 80', 'ie >= 11'],
additionalLegacyPolyfills: ['regenerator-runtime/runtime'], // regenerator-runtime/runtime @dian/polyfill
renderLegacyChunks: true,
polyfills: [
'es.symbol',
'es.array.filter',
'es.promise',
'es.promise.finally',
'es/map',
'es/set',
'es.array.for-each',
'es.object.define-properties',
'es.object.define-property',
'es.object.get-own-property-descriptor',
'es.object.get-own-property-descriptors',
'es.object.keys',
'es.object.to-string',
'web.dom-collections.for-each',
'esnext.global-this',
'esnext.string.match-all'
],
modernPolyfills: ['es.string.replace-all']
})
modernPolyfillsandpolyfillsThe difference is not clear , Gradually improve ...
- Mainstream
polyfillsThe library is core-js
边栏推荐
- Ssh server configuration file parameter permitrootlogin introduction
- Develop technology - get time 10 minutes ago
- Random talk about Clickhouse join
- 【回溯】全排列 II leetcode47
- Ten security measures against unauthorized access attacks
- 1-17 express Middleware
- Introduction to go web programming: a probe into the excellent test library gocovey
- 1-3 using SQL to manage databases
- Rethink healthy diet based on intestinal microbiome
- 1-11 create online file service
猜你喜欢

Summary of errors reported when using YML file to migrate CONDA environment

Neurotransmetteurs excitateurs - glutamate et santé cérébrale

Bloom filter

Look at the top 10 capabilities of alicloud cipu

The Jenkins download Plug-in can't be downloaded. Solution

Study summary of dynamic routing between capsules

顺祝老吴的聚会

Is Wu Enda's machine learning suitable for entry?

Introduction and example of template method mode

SQL server extracts pure numbers from strings
随机推荐
Docker installing MySQL
1-3 使用SQL管理数据库
顺祝老吴的聚会
jupyter notebook/lab 切换conda环境
USBCAN分析仪的配套CAN和CANFD综合测试软件LKMaster软件解决工程师CAN总线测试难题
jupyterbook 清空控制台输出
Best wishes for Lao Wu's party
机器学习中如何使用数据集?
jenkins下载插件下载不了,解决办法
京东与腾讯续签三年战略合作协议;起薪涨至26万元,韩国三星SK争相加薪留住半导体人才;Firefox 102 发布|极客头条
全面认识痛风:症状、风险因素、发病机理及管理
Is it safe to open an account for stock trading on mobile phones?
The programmer's girlfriend gave me a fatigue driving test
Pytorch quantitative perception training (qat) steps
Error filesystemexception: /data/nodes/0/indices/gttxk-hntgkhacm-8n60jw/1/index/ es_ temp_ File: structure needs cleaning
Three techniques for reducing debugging time of embedded software
5g demand in smart medicine
PyTorch量化实践(1)
根据肠道微生物组重新思考健康饮食
PyTorch量化实践(2)

