当前位置:网站首页>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
边栏推荐
猜你喜欢

5G 在智慧医疗中的需求

1-2 安装并配置MySQL相关的软件

AKK菌——下一代有益菌

Introduction to go web programming: a probe into the excellent test library gocovey

Is Wu Enda's machine learning suitable for entry?

介绍一款|用于多组学整合和网络可视化分析的在线平台

机器学习适合女生学吗?

Arcmap|assign values to different categories of IDS with the field calculator

机器学习中如何使用数据集?

How to use data sets in machine learning?
随机推荐
VIM common shortcut keys
Develop technology - get time 10 minutes ago
Random talk about Clickhouse join
SQL server extracts pure numbers from strings
全面认识痛风:症状、风险因素、发病机理及管理
1-1 basic concepts of database
Excuse me, can I open an account for the company? Is it safe? All the answers you want are here
1-7 path module
Ten security measures against unauthorized access attacks
Modify the name of the launched applet
1-19 利用CORS解决接口跨域问题
Study summary of dynamic routing between capsules
Develop your own package
Usbcan analyzer's supporting can and canfd comprehensive test software lkmaster software solves engineers' can bus test problems
Which direction should college students choose to find jobs after graduation?
clickhouse原生監控項,系統錶描述
Ssh server configuration file parameter permitrootlogin introduction
Clickhouse Native Monitoring item, System table Description
Test medal 1234
Is machine learning suitable for girls?

