2024-02-10 08:25:41 +00:00
|
|
|
import path from 'node:path'
|
|
|
|
import process from 'node:process'
|
|
|
|
import { loadEnv } from 'vite'
|
|
|
|
import type { ConfigEnv, UserConfig } from 'vite'
|
|
|
|
import viewport from 'postcss-mobile-forever'
|
|
|
|
import autoprefixer from 'autoprefixer'
|
|
|
|
import { createVitePlugins } from './build/vite'
|
|
|
|
|
|
|
|
export default ({ mode }: ConfigEnv): UserConfig => {
|
|
|
|
const root = process.cwd()
|
|
|
|
const env = loadEnv(mode, root)
|
|
|
|
|
|
|
|
return {
|
|
|
|
base: env.VITE_APP_PUBLIC_PATH,
|
|
|
|
plugins: createVitePlugins(),
|
|
|
|
|
|
|
|
server: {
|
|
|
|
host: true,
|
|
|
|
port: 3000,
|
|
|
|
proxy: {
|
|
|
|
'/api': {
|
|
|
|
// 接口请求地址
|
2024-02-22 07:35:23 +00:00
|
|
|
// target: 'http://localhost:8888/api',
|
2024-02-10 08:25:41 +00:00
|
|
|
target: 'https://jihui.huiyipro.com/api',
|
|
|
|
changeOrigin: true,
|
|
|
|
rewrite: path => path.replace(/^\/api/, ''),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
'~@': path.join(__dirname, './src'),
|
|
|
|
'@': path.join(__dirname, './src'),
|
|
|
|
'~': path.join(__dirname, './src/assets'),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
css: {
|
|
|
|
postcss: {
|
|
|
|
plugins: [
|
|
|
|
autoprefixer(),
|
|
|
|
viewport({
|
|
|
|
appSelector: '#app',
|
|
|
|
viewportWidth: 375,
|
|
|
|
maxDisplayWidth: 600,
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
build: {
|
|
|
|
cssCodeSplit: false,
|
|
|
|
chunkSizeWarningLimit: 2048,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|