2024-05-28 10:22:20 +08:00
|
|
|
import { cdn } from './cdn';
|
|
|
|
import vue from '@vitejs/plugin-vue';
|
|
|
|
import type { PluginOption } from 'vite';
|
|
|
|
import vueJsx from '@vitejs/plugin-vue-jsx';
|
|
|
|
import legacy from '@vitejs/plugin-legacy';
|
|
|
|
import { compression } from 'vite-plugin-compression2';
|
|
|
|
import { viteMockServe } from 'vite-plugin-mock';
|
|
|
|
import { viteBuildInfo } from './info';
|
2024-07-03 19:44:04 +08:00
|
|
|
import { configCompressPlugin } from './compress.ts';
|
2024-05-28 10:22:20 +08:00
|
|
|
|
2024-07-18 15:23:34 +08:00
|
|
|
export function getPluginsList(
|
|
|
|
VITE_CDN: boolean,
|
|
|
|
VITE_COMPRESSION: any,
|
|
|
|
VITE_PORT: string,
|
|
|
|
VITE_MOCK_SERVER_ENABLE: boolean,
|
|
|
|
): PluginOption[] {
|
2024-05-28 10:22:20 +08:00
|
|
|
return [
|
|
|
|
vue(),
|
|
|
|
legacy({
|
|
|
|
targets: ['android 4', 'ios 8', 'chrome 30', 'ie 6'],
|
|
|
|
additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
|
|
|
|
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',
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
vueJsx(),
|
|
|
|
compression(),
|
2024-07-18 15:23:34 +08:00
|
|
|
viteBuildInfo(VITE_PORT),
|
2024-07-03 19:44:04 +08:00
|
|
|
VITE_CDN ? cdn : null,
|
|
|
|
configCompressPlugin(VITE_COMPRESSION),
|
2024-07-18 15:23:34 +08:00
|
|
|
viteMockServe({
|
|
|
|
mockPath: 'src/api/mock',
|
|
|
|
enable: VITE_MOCK_SERVER_ENABLE,
|
|
|
|
watchFiles: true,
|
|
|
|
}),
|
2024-05-28 10:22:20 +08:00
|
|
|
];
|
|
|
|
}
|