123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- import { defineConfig } from 'vite'
- import path from 'path'
- import vue from '@vitejs/plugin-vue'
- import vueJsx from '@vitejs/plugin-vue-jsx'
- import raw from 'vite-raw-plugin'
- import UnoCSS from 'unocss/vite'
- import AutoImport from 'unplugin-auto-import/vite'
- import Components from 'unplugin-vue-components/vite'
- import Icons from 'unplugin-icons/vite'
- import IconsResolver from 'unplugin-icons/resolver'
- import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'
- import { loadEnv } from 'vite'
- export default defineConfig(({ mode }) => {
- const env = loadEnv(mode, process.cwd())
- return {
- base: env.VITE_ROUTER_MODE === 'hash'
- ? ''
- : '/',
- server: {
- port: 2048,
- proxy: {
- '/spark': {
- target: 'https://spark-api-open.xf-yun.com',
- changeOrigin: true,
- ws: true,
- rewrite: (path) => path.replace(/^\/spark/, '')
- },
- '/siliconflow': {
- target: 'https://api.siliconflow.cn',
- changeOrigin: true,
- ws: true,
- rewrite: (path) => path.replace(/^\/siliconflow/, '')
- },
- '/moonshot': {
- target: 'https://api.moonshot.cn',
- changeOrigin: true,
- ws: true,
- rewrite: (path) => path.replace(/^\/moonshot/, '')
- },
- '/deepseek': {
- target: 'https://api.deepseek.com',
- changeOrigin: true,
- ws: true,
- rewrite: (path) => path.replace(/^\/deepseek/, '')
- }
- }
- },
- plugins: [
- UnoCSS(),
- vue(),
- raw({
- fileRegex: /\.md$/
- }),
- vueJsx(),
- AutoImport({
- include: [
- /\.[tj]sx?$/,
- /\.vue\??/
- ],
- imports: [
- 'vue',
- 'vue-router',
- '@vueuse/core',
- {
- 'vue': [
- 'createVNode',
- 'render'
- ],
- 'vue-router': [
- 'createRouter',
- 'createWebHistory',
- 'useRouter',
- 'useRoute'
- ],
- 'uuid': [['v4', 'uuidv4']],
- 'lodash-es': [
- ['*', '_']
- ],
- 'naive-ui': [
- 'useDialog',
- 'useMessage',
- 'useNotification',
- 'useLoadingBar'
- ]
- },
- {
- from: 'vue',
- imports: [
- 'App',
- 'VNode',
- 'ComponentInternalInstance',
- 'GlobalComponents',
- 'SetupContext',
- 'PropType'
- ],
- type: true
- },
- {
- from: 'vue-router',
- imports: [
- 'RouteRecordRaw',
- 'RouteLocationRaw'
- ],
- type: true
- }
- ],
- resolvers:
- mode === 'development'
- ? []
- : [NaiveUiResolver()],
- dirs: [
- './src/hooks',
- './src/store/business',
- './src/store/transform'
- ],
- dts: './auto-imports.d.ts',
- eslintrc: {
- enabled: true
- },
- vueTemplate: true
- }),
- Components({
- directoryAsNamespace: true,
- collapseSamePrefixes: true,
- resolvers: [
- IconsResolver({
- prefix: 'auto-icon'
- }),
- NaiveUiResolver()
- ]
- }),
- // Auto use Iconify icon
- Icons({
- autoInstall: true,
- compiler: 'vue3',
- scale: 1.2,
- defaultStyle: '',
- defaultClass: 'unplugin-icon',
- jsx: 'react'
- })
- ],
- resolve: {
- extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.less', '.css'],
- alias: [
- {
- find: '@',
- replacement: path.resolve(__dirname, 'src')
- }
- ]
- },
- define: {
- 'process.env.VITE_ROUTER_MODE': JSON.stringify(env.VITE_ROUTER_MODE)
- },
- css: {
- preprocessorOptions: {
- scss: {
- api: 'modern-compiler',
- additionalData: `@use '@/styles/naive-variables.scss' as *;`
- }
- }
- }
- }
- })
|