haoxuan
2024-01-19 13f102240d9c0c9d5a133fb093551f2e08d7c55c
vite.config.ts
@@ -6,7 +6,8 @@
import IconsResolver from 'unplugin-icons/resolver'
import Icons from 'unplugin-icons/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
// 兼容低版本浏览器
import legacy from '@vitejs/plugin-legacy'
const pathSrc = path.resolve(__dirname, 'src')
// https://vitejs.dev/config/
@@ -23,7 +24,12 @@
  resolve: {
    alias: {
      '@': pathSrc
    }
    },
  },
  build: {
    target:['chrome52'],
    cssTarget:["chrome52"],
  },
  plugins: [
    vue(),
@@ -42,6 +48,32 @@
      dts: path.resolve(pathSrc, 'auto-imports.d.ts')
    }),
    // 兼容低版本浏览器
    legacy({
      targets: ['defaults', 'ie >= 11', 'chrome < 60','firefox < 59'], //需要兼容的目标列表,可以设置多个
      additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
      renderLegacyChunks: true,
      modernPolyfills: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'
      ]
    }),
    Components({
      resolvers: [
        // 自动注册图标组件
@@ -55,6 +87,12 @@
    }),
    Icons({
      autoInstall: true
    })
  ]
    }),
  ],
  configureWebpack:config=>{
    config.entry.app=['babel-polyfill','./src/main.js']
  },
  // chainWebpack: (config) => {
  //   config.entry('main').add('babel-polyfill')
  // },
})