Vite配置如下,使用@vitejs/plugin-legacy插件 同时配置 build target es2015
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import legacy from '@vitejs/plugin-legacy'
import commonjs from '@rollup/plugin-commonjs'
export default defineConfig({
plugins: [
react(),
legacy({
// IE11
targets: ['defaults', 'IE 11'],
// polyfill
additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
}),
commonjs(),
],
build: {
target: 'es2015',
},
})