当前位置:网站首页>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
边栏推荐
- PyTorch量化实践(2)
- Export El table as is to excel table
- Bloom filter
- Three techniques for reducing debugging time of embedded software
- Installing jupyter notebook under Anaconda
- 根据肠道微生物组重新思考健康饮食
- The Jenkins download Plug-in can't be downloaded. Solution
- 1. Summary of wechat applet page Jump methods; 2. the navigateto stack does not jump to the tenth floor
- 攻防演练中的防泄露全家福
- Document Layout Analysis: A Comprehensive Survey 2019论文学习总结
猜你喜欢

根据肠道微生物组重新思考健康饮食

Prediction and regression of stacking integrated model

Reading notes of Clickhouse principle analysis and Application Practice (3)

The programmer's girlfriend gave me a fatigue driving test

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

Deployment and use of Nacos

Reading notes of Clickhouse principle analysis and Application Practice (1)

阿婆做的臭豆腐

Pytorch quantitative practice (1)

机器学习工作要求研究生吗?
随机推荐
Ml & DL: Introduction à l’optimisation des hyperparamètres, indice d’évaluation, phénomène de surajustement et introduction détaillée aux méthodes d’optimisation des paramètres couramment utilisées da
Modify the name of the launched applet
Test medal 1234
Is it safe to open an account for stock trading on mobile phones?
Ssh server configuration file parameter permitrootlogin introduction
Open the jupyter notebook/lab and FAQ & settings on the remote server with the local browser
Ml & DL: introduction to hyperparametric optimization in machine learning and deep learning, evaluation index, over fitting phenomenon, and detailed introduction to commonly used parameter adjustment
Pytorch quantitative practice (1)
sdfsdf
1-2 install and configure MySQL related software
ssh 默认端口不是22时的一些问题
Notes [introduction to JUC package and future]
Export El table as is to excel table
Jupyter notebook/lab switch CONDA environment
做一个 Scrollbar 的思考
Document layout analysis: a comprehensive survey 2019 paper learning summary
"Trust machine" empowers development
Deployment and use of Nacos
微服务链路风险分析
Reading notes of Clickhouse principle analysis and Application Practice (2)

