import { defineConfig, UserConfigExport } from 'vite' import vue from '@vitejs/plugin-vue' import path from 'path' import WindiCss from 'vite-plugin-windicss'; import AutoImport from 'unplugin-auto-import/vite' import Components from 'unplugin-vue-components/vite' import { ElementPlusResolver } from 'unplugin-vue-components/resolvers' import Icons from 'unplugin-icons/vite' import IconsResolver from 'unplugin-icons/resolver' import topLevelAwait from "vite-plugin-top-level-await"; // https://vitejs.dev/config/ export default defineConfig(({ command }) => { const config: UserConfigExport = { base: '/manage/', // base: '/app/xdjy/', // base: '/app/xdhq/', resolve: { alias: { '~': `${path.resolve(__dirname, 'src')}`, '~/': `${path.resolve(__dirname, 'src/')}`, '~components': `${path.resolve(__dirname, 'src/components')}`, '@': `${path.resolve(__dirname, 'src')}`, }, }, css: { preprocessorOptions: { scss: { additionalData: `@use "~/styles/element/index.scss" as *;`, }, }, }, plugins: [ topLevelAwait({ // The export name of top-level await promise for each chunk module promiseExportName: "__tla", // The function to generate import names of top-level await promise in each chunk module promiseImportName: i => `__tla_${i}` }), vue({ reactivityTransform: true }), WindiCss(), AutoImport({ resolvers: [ElementPlusResolver()], }), Components({ resolvers: [ElementPlusResolver(), IconsResolver()], }), Icons({ compiler: 'vue3', autoInstall: true, }), ], build: { target: 'chrome86', // target: 'esnext', rollupOptions: { output: { manualChunks: { lodash: ['lodash-es'], echarts: ['echarts'], axios: ['axios'] } } } }, } if (command === 'serve') { config.base = "/" } else { } return config } )