geekai icon indicating copy to clipboard operation
geekai copied to clipboard

chore: migrate to vite

Open coderwei99 opened this issue 6 months ago • 2 comments

Background

为了提升项目的构建性能和开发体验,此 PR 完成了从 Vue CLI 到 Vite 的初步迁移工作,相关讨论见 #243 。在迁移过程中,发现了一些问题(包括 ESLint 配置缺失、统一的代码风格工具缺失等),并在此次迁移中发现一个因缺失图片资源导致打包失败的问题,已通过注释相关 <img> 标签临时修复。后续可能的话将在单独的 PR 中解决这些问题。此 PR 专注于完成 Vite 的基础配置、项目结构调整以及修复打包失败问题,确保项目能在 Vite 环境下正常运行。

Changes

  • 将项目构建工具从 Vue CLI 迁移到 Vite,更新 package.json 中的相关依赖。
  • 添加 vite.config.js 配置文件,启用 Vue 插件并设置基本构建选项。
  • 更新 index.html 和入口文件以符合 Vite 的要求。
  • 修复 stylus 路径别名问题,确保模块导入正常。为什么要这么做?
  • 注释掉一段 <img> 标签(位于 [具体文件路径,例如 src/components/xxx.vue]),因为项目中缺少相关图片资源会导致 Vite 打包失败。
  • 记录迁移中发现的问题:
    1. ESLint 配置缺失,导致代码校验规则不完整。
    2. 缺乏统一的代码风格工具(如 Prettier),可能导致代码风格不一致。
    3. web/src/views/RealtimeTest.vue 缺失图片资源导致打包失败,当前通过注释 <img> 标签临时解决。

Test Plan

  • 使用 npm run dev 在本地启动 Vite 开发服务器,确认正常运行。
  • 执行 npm run build 验证生产构建,确认注释 <img> 标签后打包成功且输出符合预期。
  • 手动测试主要功能页面(例如:首页、Ai对话),确保迁移后功能正常且注释 <img> 标签未引入新问题。
  • 测试 Vite 的 HMR(热模块替换)功能,验证组件更新实时生效。
  • 检查控制台和构建日志,确保无迁移相关或图片缺失相关的错误或警告。

PR 规则验证列表

  • [x] 确保此次 PR 只包含单一的功能修改(Vue CLI 迁移到 Vite 的核心工作及修复图片缺失导致的打包失败)。
  • [x] 我已经对我的代码更改进行了充分的测试。
  • [x] 我已经考虑了我的更改的潜在风险和缓解措施(例如,记录了 ESLint、代码风格工具及图片资源缺失问题,计划后续 PR 解决)。
  • [x] 我已经修正了相关文档(更新了 README.md 中关于 Vite 的开发和构建命令说明)。

备注

  • ESLint、代码风格工具及图片资源缺失的问题将通过单独的 PR 解决,以保持单一职责。
  • 注释 <img> 标签是临时修复,建议后续 PR 添加缺失的图片资源或调整相关逻辑。
  • 欢迎审阅者提供关于 Vite 配置优化、图片资源处理或其他潜在问题的反馈。

coderwei99 avatar May 22 '25 01:05 coderwei99

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

Since your pull request originates from a forked repository, GitGuardian is not able to associate the secrets uncovered with secret incidents on your GitGuardian dashboard. Skipping this check run and merging your pull request will create secret incidents on your GitGuardian dashboard.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
- - Generic Password 4f15cec9ea1acee7489b5ab587e5257e6260a5f2 web/src/views/Login.vue View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

gitguardian[bot] avatar May 22 '25 01:05 gitguardian[bot]

经过我本地的测试,我认为这条 PR 没有引起别的问题。如果你们认为依旧存在潜在问题,欢迎随时与我沟通。

coderwei99 avatar Jun 23 '25 03:06 coderwei99