123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- 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
- }
- )
|