mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-09 02:24:11 +08:00
- Added LICENSE.txt file for JavaScript assets in the build directory, including licenses for NProgress and React libraries. - Introduced a new runtime JavaScript file for handling module loading. - Created a new DocItem component to manage document rendering and metadata handling in the Docusaurus theme. - Implemented tests for the docs proxy server to ensure proper routing to the configured docsPort.
81 lines
2.4 KiB
TypeScript
81 lines
2.4 KiB
TypeScript
import { defineConfig } from 'vite'
|
|
import react from '@vitejs/plugin-react'
|
|
import path from 'path'
|
|
import { fileURLToPath } from 'url'
|
|
|
|
// ES module equivalent of __dirname
|
|
const __filename = fileURLToPath(import.meta.url)
|
|
const __dirname = path.dirname(__filename)
|
|
|
|
// Get base path from environment variable
|
|
// Default to /react/ for development (CCW server proxies /react/* to Vite)
|
|
// Can be overridden by VITE_BASE_URL environment variable
|
|
const basePath = process.env.VITE_BASE_URL || '/react/'
|
|
|
|
// Backend target for Vite proxy (used when directly opening the Vite dev server port).
|
|
// In `ccw view`, this is set to the dashboard server port so /api, /ws, and /docs all route correctly.
|
|
const backendHost = process.env.VITE_BACKEND_HOST || 'localhost'
|
|
const backendPort = Number(process.env.VITE_BACKEND_PORT || '3456')
|
|
const backendHttpTarget = `http://${backendHost}:${backendPort}`
|
|
const backendWsTarget = `ws://${backendHost}:${backendPort}`
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
base: basePath,
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, './src'),
|
|
},
|
|
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
|
|
},
|
|
server: {
|
|
// Don't hardcode port - allow command line override
|
|
// strictPort: true ensures the specified port is used or fails
|
|
strictPort: true,
|
|
proxy: {
|
|
// Backend API proxy
|
|
'/api': {
|
|
target: backendHttpTarget,
|
|
changeOrigin: true,
|
|
},
|
|
// WebSocket proxy for real-time updates
|
|
'/ws': {
|
|
target: backendWsTarget,
|
|
ws: true,
|
|
},
|
|
// Docs proxy
|
|
// Forwards /docs requests to the dashboard server, which proxies to the docs server.
|
|
'/docs': {
|
|
target: backendHttpTarget,
|
|
changeOrigin: true,
|
|
// Preserve /docs prefix to match the dashboard's /docs proxy and Docusaurus baseUrl.
|
|
// Example: /docs/overview -> http://localhost:{backendPort}/docs/overview
|
|
},
|
|
},
|
|
},
|
|
build: {
|
|
outDir: 'dist',
|
|
sourcemap: true,
|
|
},
|
|
test: {
|
|
globals: true,
|
|
environment: 'jsdom',
|
|
setupFiles: './src/test/setup.ts',
|
|
coverage: {
|
|
provider: 'v8',
|
|
reporter: ['text', 'json', 'html'],
|
|
exclude: [
|
|
'node_modules/',
|
|
'src/test/',
|
|
'**/*.d.ts',
|
|
'**/*.config.*',
|
|
'**/mockData/*',
|
|
'src/main.tsx',
|
|
],
|
|
},
|
|
include: ['src/**/*.{test,spec}.{ts,tsx}'],
|
|
css: true,
|
|
},
|
|
})
|