Files
testing-tool/wxt.config.ts
rsgltzyd c7f4305fc3 refactor: 重构 RouterContainer 组件以支持懒加载页面模块
- 移除不必要的 Suspense 组件,改为使用 LoadedPage 组件进行懒加载。
- 更新特性获取逻辑,使用 getFeatureByKey 函数替代直接查找。
- 新增 featureMeta.ts 文件,集中管理功能配置和相关方法。
- 实现 pageLoaders 以支持按需加载页面模块,提升性能和用户体验。
2026-06-30 22:45:32 +08:00

85 lines
2.0 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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';
}
// qrious / qr-scanner / @dnd-kit 不单独拆 vendor chunk
// 独立 vendor 会与 Vite preload 辅助函数共 chunk,被 App Shell 静态拉取。
// 这些依赖随各自页面 async chunk 加载即可。
return undefined;
},
};
},
};
}
export default defineConfig({
modules: ['@wxt-dev/module-react'],
srcDir: 'src',
manifest: {
name: 'Testing Tool',
description: 'A tool for testing web applications.',
version_name: undefined,
permissions: [
'storage',
'clipboardWrite',
'scripting',
'tabs',
'cookies',
'sidePanel',
'contextMenus',
],
host_permissions: ['<all_urls>'],
icons: {
'16': 'icon/16.png',
'32': 'icon/32.png',
'48': 'icon/48.png',
'96': 'icon/96.png',
'128': 'icon/128.png',
},
action: {
default_title: 'Testing Tool',
default_icon: {
'16': 'icon/16.png',
'32': 'icon/32.png',
'48': 'icon/48.png',
},
},
side_panel: {
default_path: 'entrypoints/sidepanel/index.html',
},
},
vite: () => ({
plugins: [manualChunksForHtmlOnly()],
build: {
modulePreload: false,
minify: 'terser',
terserOptions: {
format: { ascii_only: true, comments: false },
},
chunkSizeWarningLimit: 800,
},
}),
});