You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
import { loadEnv } from 'vite' ;
import { viteMockServe } from 'vite-plugin-mock' ;
import { createVuePlugin } from 'vite-plugin-vue2' ;
import { createSvgPlugin } from 'vite-plugin-vue2-svg' ;
import requireTransform from 'vite-plugin-require-transform' ;
import path from 'path' ;
const CWD = process . cwd ( ) ;
export default ( { mode } ) => {
const { VITE _BASE _URL } = loadEnv ( mode , CWD ) ;
return {
base : VITE _BASE _URL ,
resolve : {
alias : {
'~' : path . resolve ( _ _dirname , './' ) ,
'@' : path . resolve ( _ _dirname , './src' ) ,
} ,
} ,
css : {
preprocessorOptions : {
less : {
modifyVars : { } ,
} ,
} ,
} ,
plugins : [
createVuePlugin ( {
jsx : true ,
} ) ,
viteMockServe ( {
mockPath : 'mock' ,
localEnabled : true ,
} ) ,
createSvgPlugin ( ) ,
requireTransform (
{
fileRegex : /.vue$/
}
) ,
] ,
build : {
cssCodeSplit : false ,
emptyOutDir : true ,
minify : 'terser' ,
terserOptions : {
compress : {
//生产环境时移除console.log()
drop _console : true ,
drop _debugger : true ,
} ,
} ,
} ,
server : {
host : '::' ,
port : 3001 ,
proxy : {
'/api' : {
// 用于开发环境下的转发请求
// 更多请参考: https://vitejs.dev/config/#server-proxy
target : 'https://127.0.0.1' ,
changeOrigin : true ,
} ,
} ,
} ,
} ;
} ;