【调整】打包调整

This commit is contained in:
chenzhihua
2025-07-17 14:34:59 +08:00
parent 074f2c5903
commit 85734cfcf8
46 changed files with 44 additions and 98 deletions

View File

@@ -1,18 +0,0 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="./favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>AllinSSL</title>
<script>
// SPA路由回退处理
// 将当前路径存储到sessionStorage然后重定向到根路径
sessionStorage.setItem('redirectPath', location.pathname + location.search + location.hash);
location.replace('/');
</script>
</head>
<body>
<div id="app"></div>
</body>
</html>

View File

@@ -16,14 +16,6 @@ const useRouterEach = (router: Router) =>
beforeEach: (to: RouteLocationNormalized, _: RouteLocationNormalized, next: NavigationGuardNext) => {
// 开始加载
loadingBar.start()
// 处理SPA路由回退重定向
const redirectPath = sessionStorage.getItem('redirectPath')
if (redirectPath && to.path === '/') {
sessionStorage.removeItem('redirectPath')
return next(redirectPath)
}
// 判断当前路由是否存在,如果不存在,则跳转到 404
if (!router.hasRoute(to.name as string)) {
if (!to.path.includes('/404')) return next({ path: '/404' })

View File

@@ -183,18 +183,6 @@ export default defineConfig({
chunkSizeWarningLimit: 800, // 警告阈值
assetsInlineLimit: 2048, // 小于2kb的资源内联
modulePreload: false, // 禁用预加载
// SPA路由支持生成404.html作为回退页面
rollupOptions: {
input: {
main: path.resolve(__dirname, 'index.html'),
},
output: {
// 确保资源路径正确
assetFileNames: 'static/[ext]/[name]-[hash].[ext]',
chunkFileNames: 'static/js/[name]-[hash].js',
entryFileNames: 'static/js/[name]-[hash].js',
},
},
terserOptions: {
// 打包后移除console和注释
compress: {
@@ -208,7 +196,6 @@ export default defineConfig({
},
strictDeprecations: true, // 严格弃用
output: {
// 确保资源路径正确支持SPA路由
entryFileNames: `${packPath}js/[name]-[hash].js`,
chunkFileNames: `${packPath}js/[name]-[hash].js`,
assetFileNames: (chunkInfo) => {
@@ -240,4 +227,7 @@ export default defineConfig({
},
},
},
test: {
include: ['src/**/*.spec.ts'],
},
})