修复退役样式开发态加载

将退役 CSS 源码过滤调整到 Tailwind 转换前执行
新增 Vite 插件顺序回归测试
补充退役方案与开发态白屏排障记录
This commit is contained in:
2026-07-18 15:12:09 +08:00
parent e9c3dc1120
commit f625fe8e8b
4 changed files with 34 additions and 1 deletions
@@ -14,6 +14,14 @@
- 关联:相关文件、文档、提交或 Issue
```
## Vite 源码 CSS 清理插件必须早于 Tailwind 执行
- 现象:生产构建通过,但本地 dev 打开主站后全页白屏,`/src/index.css` 返回 500Vite 报 `Unknown word updateStyle`
- 原因:自定义 CSS 插件使用 `enforce: 'post'`,在 Tailwind/Vite 已把 CSS 转为包含 `updateStyle` import 的 JavaScript 模块后,仍调用 `postcss.parse`
- 处理:需要改写原始 CSS 的 transform 固定使用 `enforce: 'pre'`;最终构建产物清理继续放在 `generateBundle`,不要混用两个阶段的输入格式。
- 验证:真实启动 `npm run dev` 后请求 `/src/index.css` 必须返回 200,并在浏览器确认 `#root` 已挂载且控制台无 CSS transform 错误。
- 关联:`vite.config.ts``scripts/vite-retired-css-plugin.test.ts`
## phase 上报的业务拒绝与传输失败不能共用字符串错误
- 现象:provider 已经返回并保存原图,worker 上报 `processing` 时一次断连或超时就直接把任务判为失败;或者为了规避误杀而重试所有错误,导致 stale lease 的旧 worker 继续执行后处理。
@@ -35,6 +35,7 @@
- 正式应用入口使用 `active-main.tsx``ActiveApp.tsx``routing/activeAppRoutes.tsx``routing/activeAppPageRoutes.ts``services/activeAppTitle.ts``platform-entry/PlatformEntryActiveFlowShell.tsx``platformEntryActiveTypes.ts`;原同名非 active 文件保持历史源码原貌并退出 Vite、TypeScript、ESLint 和 Vitest。
- 旧业务源码与素材保留在仓库中;Vite 不得再引用入口或动态 importTypeScript、ESLint、Vitest 必须明确排除旧目录和专属测试。退役源码只用于历史追溯,不允许从在运代码重新导入。
-`main.tsx``App.tsx`、旧路由、旧标题映射、`PlatformEntryFlowShellImpl.tsx` 与旧入口类型保持原样;正式链路由 `active-main.tsx``ActiveApp.tsx``activeApp*``PlatformEntryActiveFlowShell.tsx``platformEntryActiveTypes.ts` 承载,只包含项目、编辑器、账号、设置与钱包公共能力。`retired/legacy-creation-templates/frontend/original/` 另保留逐文件原样快照。
- 退役 CSS 的源码过滤必须在 Tailwind/Vite 转换前执行,产物过滤留在 `generateBundle`;禁止在 `post` transform 中把 Vite 已生成的 JavaScript 样式模块重新交给 PostCSS 解析。
- 旧 URL 统一回落到当前平台公共首页,不再提供旧业务错误页、详情页或兼容壳。
### Rust
+24
View File
@@ -0,0 +1,24 @@
import type { Plugin } from 'vite';
import { describe, expect, it } from 'vitest';
import viteConfig from '../vite.config';
async function resolveRetiredCssPlugin() {
const resolvedConfig =
typeof viteConfig === 'function'
? await viteConfig({ command: 'serve', mode: 'test' })
: viteConfig;
const plugins = (resolvedConfig.plugins ?? []).flat(Infinity) as Plugin[];
return plugins.find(
(plugin) => plugin?.name === 'retired-creation-template-css',
);
}
describe('retired creation template CSS plugin', () => {
it('runs before Tailwind turns source CSS into a Vite JavaScript module', async () => {
const plugin = await resolveRetiredCssPlugin();
expect(plugin).toBeDefined();
expect(plugin?.enforce).toBe('pre');
});
});
+1 -1
View File
@@ -115,7 +115,7 @@ function retiredCreationTemplateCssPlugin(): Plugin {
return {
name: 'retired-creation-template-css',
enforce: 'post',
enforce: 'pre',
transform(code, id) {
if (
!id.endsWith('/src/index.css') &&