aa23a263fe
- 移除 react-i18next、i18next 及相关依赖
- 删除旧的 i18n/ 目录和 useLazyTranslation 工具
- 新增 utils/chromeI18n.ts 类型安全 wrapper(useI18n Hook + getMessage)
- 生成 public/_locales/{zh,en}/messages.json(298 个翻译 key)
- 批量更新 39+ 组件文件的导入和翻译调用
- 转换翻译键格式:namespace:key → namespace_key
- 修复 ErrorBoundary/PageErrorBoundary 从 withTranslation HOC 改为直接调用 getMessage
- 更新 vitest.setup.ts mock 加载实际翻译文本
- 修复 11 个测试文件的断言以匹配中文翻译
- TypeScript、ESLint、547 项测试全部通过
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
87 lines
2.1 KiB
TypeScript
87 lines
2.1 KiB
TypeScript
import { defineConfig } from 'wxt';
|
|
import type { Plugin } from 'vite';
|
|
|
|
function manualChunksForHtmlOnly(): Plugin {
|
|
return {
|
|
name: 'manual-chunks-html-only',
|
|
outputOptions(rawOptions) {
|
|
if (rawOptions.format === 'iife' || rawOptions.format === 'umd') {
|
|
return;
|
|
}
|
|
|
|
return {
|
|
...rawOptions,
|
|
manualChunks(id: string): string | void {
|
|
if (!id.includes('node_modules')) {
|
|
return undefined;
|
|
}
|
|
|
|
if (
|
|
id.includes('/react-dom/') ||
|
|
(id.includes('/react/') && !id.includes('/react-dom/'))
|
|
) {
|
|
return 'vendor-react';
|
|
}
|
|
// 二维码活态感知依赖分流
|
|
if (id.includes('qr-scanner') || id.includes('qrious')) {
|
|
return 'vendor-qr';
|
|
}
|
|
// 拖拽排序高级组件分流
|
|
if (id.includes('@dnd-kit')) {
|
|
return 'vendor-dnd';
|
|
}
|
|
// Markdown 高性能转换引擎分流
|
|
if (id.includes('marked')) {
|
|
return 'vendor-markdown';
|
|
}
|
|
|
|
return undefined;
|
|
},
|
|
};
|
|
},
|
|
};
|
|
}
|
|
|
|
export default defineConfig({
|
|
modules: ['@wxt-dev/module-react'],
|
|
manifest: {
|
|
name: 'Testing Tool',
|
|
description: 'A tool for testing web applications.',
|
|
version_name: undefined,
|
|
default_locale: 'zh',
|
|
permissions: [
|
|
'storage',
|
|
'unlimitedStorage',
|
|
'clipboardWrite',
|
|
'activeTab',
|
|
'scripting',
|
|
'tabs',
|
|
'cookies',
|
|
'sidePanel',
|
|
'contextMenus',
|
|
'alarms',
|
|
],
|
|
host_permissions: ['<all_urls>'],
|
|
action: {
|
|
default_title: '__MSG_appName__',
|
|
},
|
|
side_panel: {
|
|
default_path: 'entrypoints/sidepanel/index.html',
|
|
},
|
|
options_ui: {
|
|
page: 'entrypoints/options/index.html',
|
|
open_in_tab: true,
|
|
},
|
|
},
|
|
vite: () => ({
|
|
plugins: [manualChunksForHtmlOnly()],
|
|
build: {
|
|
minify: 'terser',
|
|
terserOptions: {
|
|
format: { ascii_only: true, comments: false },
|
|
},
|
|
chunkSizeWarningLimit: 800,
|
|
},
|
|
}),
|
|
});
|