grailed/grailed_app/vite.config.ts

55 lines
1.3 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { fileURLToPath, URL } from 'node:url'
import path from 'path'
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite';
import { VantResolver } from '@vant/auto-import-resolver';
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite'
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
// 根据当前模式development 或 production获取对应的环境变量
return {
plugins: [
vue(),
VueI18nPlugin({}),
Components({
resolvers: [VantResolver()],
}),
createSvgIconsPlugin({
iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
symbolId: 'icon-[dir]-[name]',
})
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
build: {
assetsDir: 'assets',
base: './',
minify: 'terser',
outDir: env.VITE_OUT_DIR || 'dist',
terserOptions: {
compress: {
drop_console: true
}
}
},
server: {
https: false,
port: 3000,
host: "0.0.0.0",
proxy: {
'/app-api': {
target: env.VITE_BASE_URL,
}
}
}
}})