Files
router-studio/vite.config.ts
xiongxiao 64eabb7aa8 feat: update dependencies and add new features
- Update package.json dependencies (@tanstack/react-query, @kevisual/*, etc.)
- Add openLink utility function in basename.ts
- Add stackQueryClient for React Query in query.ts
- Refactor auth store with serverData and query hooks
- Add demo route and auth hooks
- Add VitePWA plugin and env config
- Update AGENTS.md documentation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-19 01:15:03 +08:00

53 lines
1.4 KiB
TypeScript

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path';
import pkgs from './package.json';
import tailwindcss from '@tailwindcss/vite';
import { tanstackRouter } from '@tanstack/router-plugin/vite'
import dotenv from 'dotenv';
import { VitePWA } from 'vite-plugin-pwa';
const env = dotenv.config().parsed || {};
const isDev = env.NODE_ENV === 'development' || process.env.NODE_ENV === 'development';
const basename = isDev ? '/' : pkgs?.basename || '/';
let target = env.VITE_API_URL || process.env.API_URL || 'http://localhost:51515';
const apiProxy = { target: target, changeOrigin: true, ws: true, rewriteWsOrigin: true, secure: false, cookieDomainRewrite: 'localhost' };
let proxy = {
'/root/': apiProxy,
'/api': apiProxy,
'/client': apiProxy,
};
/**
* @see https://vitejs.dev/config/
*/
export default defineConfig({
plugins: [
// Please make sure that '@tanstack/router-plugin' is passed before '@vitejs/plugin-react'
tanstackRouter({
target: 'react',
autoCodeSplitting: true,
}),
react(),
tailwindcss(),
VitePWA({
injectRegister: 'auto',
}),
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
base: basename,
define: {
BASE_NAME: JSON.stringify(basename),
},
server: {
port: 7008,
host: '0.0.0.0',
allowedHosts: true,
proxy,
},
});