Files
suzmii c0db298449
Project CI / AI game creator shell Rust shard 1/4 (pull_request) Successful in 5m12s
Project CI / AI game creator shell Rust shard 2/4 (pull_request) Successful in 5m29s
Project CI / AI game creator shell Rust shard 3/4 (pull_request) Successful in 4m46s
Project CI / AI game creator shell Rust smoke (pull_request) Successful in 1m43s
Project CI / Backend tests (pull_request) Failing after 11s
Project CI / AI game creator shell Rust shard 4/4 (pull_request) Successful in 4m38s
Project CI / Repository checks (pull_request) Failing after 10s
Project CI / AI game creator shell Rust crates (pull_request) Successful in 2m31s
Project CI / AI game creator shell web tests (pull_request) Failing after 4m35s
Project CI / Frontend tests (pull_request) Successful in 6m38s
Project CI / Native shell tests (pull_request) Successful in 8m25s
修复 AGC 开发态监听 Rust 构建目录导致的加载缓慢
在 Vite 中排除 src-tauri/target,保留业务源码与共享组件热更新。
增加实际 Vite watcher 回归,验证构建目录排除及源码变更通知。
同步开发运维文档和共享排障记录,关联 Issue #324。
2026-09-16 11:27:07 +08:00

175 lines
4.5 KiB
TypeScript

import { existsSync, readFileSync } from 'node:fs';
import { createRequire } from 'node:module';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import tailwindcss from '@tailwindcss/vite';
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
const appRoot = dirname(fileURLToPath(import.meta.url));
const repoRoot = resolve(appRoot, '../..');
const appRequire = createRequire(resolve(appRoot, 'package.json'));
const reactFileManagerPackageRoot = dirname(
appRequire.resolve('@cubone/react-file-manager/package.json'),
);
function resolveDevApiTarget() {
const statePath = resolve(repoRoot, '.app/dev-stack.json');
if (!existsSync(statePath)) {
return 'http://127.0.0.1:8082';
}
try {
const state = JSON.parse(readFileSync(statePath, 'utf8')) as {
services?: {
'api-server'?: {
status?: string;
url?: string;
};
};
};
const apiServer = state.services?.['api-server'];
if (
apiServer &&
['running', 'reused', 'starting'].includes(apiServer.status ?? '') &&
apiServer.url
) {
return apiServer.url;
}
return 'http://127.0.0.1:8082';
} catch {
return 'http://127.0.0.1:8082';
}
}
const apiTarget = resolveDevApiTarget();
export default defineConfig({
root: appRoot,
plugins: [
tailwindcss(),
react(),
{
name: 'genarrative-ai-game-creator-dev-marker',
configureServer(server) {
server.middlewares.use(
'/__agc_dev_server.json',
(_request, response) => {
response.setHeader(
'Content-Type',
'application/json; charset=utf-8',
);
response.end(
JSON.stringify({
schemaVersion: 1,
app: 'ai-game-creator-shell',
repoRoot,
processId: process.pid,
port: server.config.server.port,
apiTarget,
}),
);
},
);
},
},
],
resolve: {
alias: [
// v1.35.0 publishes this bundle but its package metadata points Vite at
// an incomplete source entrypoint. Resolve only the bare module to the
// published ESM artifact; its stylesheet remains a valid subpath import.
{
find: /^@cubone\/react-file-manager$/,
replacement: resolve(
reactFileManagerPackageRoot,
'dist/react-file-manager.es.js',
),
},
{
find: '@genarrative/image-canvas-core',
replacement: resolve(
repoRoot,
'packages/image-canvas-core/src/index.ts',
),
},
{
find: '@genarrative/image-canvas-react/styles.css',
replacement: resolve(
repoRoot,
'packages/image-canvas-react/src/styles.css',
),
},
{
find: '@genarrative/image-canvas-react',
replacement: resolve(
repoRoot,
'packages/image-canvas-react/src/index.ts',
),
},
{
find: '@genarrative/shared/styles.css',
replacement: resolve(
repoRoot,
'packages/shared/src/components/styles.css',
),
},
{
find: '@genarrative/shared/theme.css',
replacement: resolve(repoRoot, 'packages/shared/src/theme.css'),
},
{
find: '@genarrative/shared/components/ui',
replacement: resolve(
repoRoot,
'packages/shared/src/components/ui/index.ts',
),
},
{
find: '@genarrative/shared/lib',
replacement: resolve(repoRoot, 'packages/shared/src/lib'),
},
{
find: '@genarrative/shared/components/account',
replacement: resolve(
repoRoot,
'packages/shared/src/components/account.ts',
),
},
{
find: '@genarrative/shared/components',
replacement: resolve(
repoRoot,
'packages/shared/src/components/index.ts',
),
},
{
find: '@genarrative/shared',
replacement: resolve(repoRoot, 'packages/shared/src/index.ts'),
},
],
dedupe: ['react', 'react-dom'],
},
server: {
host: '127.0.0.1',
port: 3080,
strictPort: true,
watch: {
ignored: ['**/src-tauri/target/**'],
},
fs: {
allow: [repoRoot],
},
proxy: {
'/api': {
target: apiTarget,
changeOrigin: true,
},
},
},
build: {
outDir: resolve(appRoot, 'dist'),
emptyOutDir: true,
},
});