goploy/web+/vite.config.ts

42 lines
1.3 KiB
TypeScript
Raw Normal View History

2021-05-14 20:35:22 +08:00
import { defineConfig, loadEnv, ConfigEnv, UserConfigExport } from 'vite'
import path from 'path'
import vue from '@vitejs/plugin-vue'
import vueI18n from '@intlify/vite-plugin-vue-i18n'
import viteSvgIcons from 'vite-plugin-svg-icons'
// https://vitejs.dev/config/
export default ({ mode }: ConfigEnv): UserConfigExport => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) }
return defineConfig({
resolve: {
alias: [{ find: '@', replacement: path.resolve(__dirname, 'src') }],
},
plugins: [
vue(),
vueI18n({
include: path.resolve(__dirname, './src/lang/**'),
}),
viteSvgIcons({
// Specify the icon folder to be cached
iconDirs: [path.resolve(__dirname, './src/icons/svg')],
// Specify symbolId format
symbolId: 'icon-[dir]-[name]',
}),
],
server: {
proxy: {
// change xxx-api/login => mock/login
// detail: https://cli.vuejs.org/config/#devserver-proxy
[process.env.VITE_APP_BASE_API]: {
target: process.env.VITE_APP_PROXY_TARGET,
changeOrigin: true,
rewrite: (path) => {
const reg = RegExp('^' + process.env.VITE_APP_BASE_API)
return path.replace(reg, '')
},
2021-05-20 17:25:57 +08:00
ws: true,
2021-05-14 20:35:22 +08:00
},
},
},
})
}