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' // https://vitejs.dev/config/ export default defineConfig(({ command, mode }) => { const config: UserConfigExport = { // base:'/app/xdjx/', // 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: [ vue(), WindiCss(), AutoImport({ resolvers: [ElementPlusResolver()], }), Components({ resolvers: [ElementPlusResolver()], }), ], build: { // target: 'modules' target: 'esnext', rollupOptions: { output: { manualChunks: { lodash: ['lodash-es'], echarts: ['echarts'], axios: ['axios'] } } } }, server: { port: 3000 } } if (command === 'serve') { config.base = '/' } if (command === 'build') { switch (mode) { case 'xdhq': config.base = '/app/xdhq/' break; case 'xdjy': config.base = '/app/xdjy/' break; case 'xdjx': config.base = '/app/xdjx/' break; default: config.base = '/' } } return config } )