import type { UserConfigExport , ConfigEnv } from 'vite' ; import { loadEnv } from 'vite' ; import reactRefresh from '@vitejs/plugin-react-refresh' ; import { viteMockServe } from 'vite-plugin-mock' ; import { resolve } from 'path' ; import svgr from 'vite-plugin-svgr' ; import { getAliases } from "vite-aliases" ; import styleImport from 'vite-plugin-style-import' ; const aliases = getAliases ( ) ; function pathResolve ( dir ) { return resolve ( __dirname , '.' , dir ) ; } export default ( { command } ) => { console . log ( 'command:' ) ; return { resolve : { alias : [ { find : /^~/ , replacement : pathResolve ( 'node_modules' ) + '/' , } , { find : /@\// , replacement : pathResolve ( 'src' ) + '/' , } , ] , } , optimizeDeps : { include : [ '@ant-design/colors' , '@ant-design/icons' , ] , } , plugins : [ reactRefresh ( ) , svgr ( ) , viteMockServe ( { mockPath : 'mock' , supportTs : true , watchFiles : true , localEnabled : command === 'serve' , logger : true , } ) , ] , css : { modules : { localsConvention : 'camelCaseOnly' , } , preprocessorOptions : { less : { javascriptEnabled : true , modifyVars : { '@primary-color' : '#1890ff' , } , } , } , } , } ; } ;