|
@@ -13,6 +13,7 @@ import viteCompression from "vite-plugin-compression";
|
|
import { createHtmlPlugin } from "vite-plugin-html";
|
|
import { createHtmlPlugin } from "vite-plugin-html";
|
|
import { enableCDN } from "./build/cdn";
|
|
import { enableCDN } from "./build/cdn";
|
|
import { ViteImageOptimizer } from 'vite-plugin-image-optimizer';
|
|
import { ViteImageOptimizer } from 'vite-plugin-image-optimizer';
|
|
|
|
+import legacy from '@vitejs/plugin-legacy';
|
|
|
|
|
|
// 当前工作目录路径
|
|
// 当前工作目录路径
|
|
const root: string = process.cwd();
|
|
const root: string = process.cwd();
|
|
@@ -67,6 +68,33 @@ export default defineConfig(({ mode }) => {
|
|
vueTemplate: true, // 是否在 vue 模板中自动导入
|
|
vueTemplate: true, // 是否在 vue 模板中自动导入
|
|
|
|
|
|
}),
|
|
}),
|
|
|
|
+ legacy({
|
|
|
|
+ targets: ['defaults', 'Chrome >= 51'],
|
|
|
|
+ additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
|
|
|
|
+ modernPolyfills: ['es.string.replace-all'],
|
|
|
|
+ renderLegacyChunks: true,
|
|
|
|
+ polyfills: [
|
|
|
|
+ 'es.array.flat-map',
|
|
|
|
+ 'es.array.filter',
|
|
|
|
+ 'es.promise',
|
|
|
|
+ 'es.promise.finally',
|
|
|
|
+ 'es.object.assign',
|
|
|
|
+ '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',
|
|
|
|
+ 'es.array.iterator',
|
|
|
|
+ 'es.string.includes',
|
|
|
|
+ 'es.string.starts-with',
|
|
|
|
+ 'es.object.values'
|
|
|
|
+ ]
|
|
|
|
+ }),
|
|
// 生产环境默认不启用 CDN 加速
|
|
// 生产环境默认不启用 CDN 加速
|
|
enableCDN(env.VITE_CDN_DEPS),
|
|
enableCDN(env.VITE_CDN_DEPS),
|
|
ViteImageOptimizer()
|
|
ViteImageOptimizer()
|