fix: 优化浏览器兼容策略
This commit is contained in:
27
.babelrc.json
Normal file
27
.babelrc.json
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"plugins": [
|
||||||
|
[
|
||||||
|
"@babel/plugin-transform-runtime",
|
||||||
|
{
|
||||||
|
"corejs": 3
|
||||||
|
}
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"presets": [
|
||||||
|
[
|
||||||
|
"@babel/preset-env",
|
||||||
|
{
|
||||||
|
"targets": {
|
||||||
|
"ie": "11",
|
||||||
|
"chrome": "58",
|
||||||
|
"safari": "11.1",
|
||||||
|
"firefox": "63",
|
||||||
|
"edge": "16"
|
||||||
|
},
|
||||||
|
"corejs": 3,
|
||||||
|
"useBuiltIns": "usage",
|
||||||
|
"modules": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
@@ -6,8 +6,8 @@ import routeConfig from './router'
|
|||||||
import 'virtual:svg-icons-register'
|
import 'virtual:svg-icons-register'
|
||||||
import { Provider as MobxProvider } from 'mobx-react'
|
import { Provider as MobxProvider } from 'mobx-react'
|
||||||
import { RootStore } from '@/store'
|
import { RootStore } from '@/store'
|
||||||
import 'core-js/stable'
|
import 'core-js';
|
||||||
import 'regenerator-runtime/runtime'
|
import 'regenerator-runtime/runtime';
|
||||||
const router = createBrowserRouter(routeConfig)
|
const router = createBrowserRouter(routeConfig)
|
||||||
ReactDOM.createRoot(document.getElementById('root')!).render(
|
ReactDOM.createRoot(document.getElementById('root')!).render(
|
||||||
// <React.StrictMode>
|
// <React.StrictMode>
|
||||||
|
@@ -7,8 +7,7 @@ import * as path from 'path'
|
|||||||
import imagemin from 'unplugin-imagemin/vite'
|
import imagemin from 'unplugin-imagemin/vite'
|
||||||
import viteCompression from 'vite-plugin-compression'
|
import viteCompression from 'vite-plugin-compression'
|
||||||
import {createHtmlPlugin} from 'vite-plugin-html'
|
import {createHtmlPlugin} from 'vite-plugin-html'
|
||||||
// import legacy from '@vitejs/plugin-legacy'
|
import legacy from '@vitejs/plugin-legacy'
|
||||||
import { babel } from '@rollup/plugin-babel'
|
|
||||||
import postcssPresetEnv from 'postcss-preset-env'
|
import postcssPresetEnv from 'postcss-preset-env'
|
||||||
import autoprefixer from 'autoprefixer'
|
import autoprefixer from 'autoprefixer'
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
@@ -20,13 +19,31 @@ export default defineConfig(({ mode }) => {
|
|||||||
base: '/',
|
base: '/',
|
||||||
plugins: [
|
plugins: [
|
||||||
react(),
|
react(),
|
||||||
// legacy({
|
legacy({
|
||||||
// targets: ['ie >= 11', 'chrome 52', 'Chrome > 70', 'Safari 12.1', 'ios >= 12.3'],
|
targets: ['ie >= 11', 'chrome 52', 'Chrome > 70', 'Safari 12.1', 'last 2 versions and since 2018 and > 0.5%', 'iOS >= 9','Android >= 4.4','last 2 versions'],
|
||||||
// additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
|
additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
|
||||||
// renderLegacyChunks: true,
|
renderLegacyChunks: true,
|
||||||
// polyfills: ['es.promise.all-settled', 'es.object.entries'],
|
polyfills: [
|
||||||
// modernPolyfills: ['es.promise.all-settled', 'es.object.entries'],
|
'es.promise.all-settled',
|
||||||
// }),
|
'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.promise.all-settled', 'es.object.entries', 'es.string.replace-all'],
|
||||||
|
}),
|
||||||
// 修改 icons 相关配置
|
// 修改 icons 相关配置
|
||||||
createSvgIconsPlugin({
|
createSvgIconsPlugin({
|
||||||
// 指定需要缓存的图标文件夹
|
// 指定需要缓存的图标文件夹
|
||||||
@@ -137,26 +154,6 @@ export default defineConfig(({ mode }) => {
|
|||||||
brotliSize: true, // 启用 brotli 压缩大小报告
|
brotliSize: true, // 启用 brotli 压缩大小报告
|
||||||
chunkSizeWarningLimit: 2000, // chunk 大小警告的限制
|
chunkSizeWarningLimit: 2000, // chunk 大小警告的限制
|
||||||
watch: null, // 设置为 {} 则会启用 rollup 的监听器
|
watch: null, // 设置为 {} 则会启用 rollup 的监听器
|
||||||
rollupOptions: {
|
|
||||||
plugins: [
|
|
||||||
// https://www.npmjs.com/package/@rollup/plugin-babel
|
|
||||||
babel({
|
|
||||||
babelHelpers: 'bundled',
|
|
||||||
presets: [
|
|
||||||
[
|
|
||||||
'@babel/preset-env',
|
|
||||||
{
|
|
||||||
useBuiltIns: 'entry', // 注意这里只能使用 entry
|
|
||||||
corejs: '3',
|
|
||||||
targets: 'last 2 versions and not dead, > 0.2%, Firefox ESR',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
],
|
|
||||||
plugins: [],
|
|
||||||
compact: false,
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
proxy: {
|
proxy: {
|
||||||
|
Reference in New Issue
Block a user