Keepfast v0.2.1 釋出了,Keepfast 是一個效能分析工具,能夠分析網站的資源構建效能和頁面效能,生成效能報告並提供最佳化建議,讓效能監控更方便。目前已用在碼雲內部為前端專案提供效能監控支援。
這是第一個公開發行版,以下做些簡單的介紹。
訪問此頁面可檢視效能報告效果:
npm install -g lighthouse @gitee/keepfast
先為你的專案建立配置檔案:
# 進入你的專案目錄 cd /path/to/your/repo # 初始化配置檔案 keepfast init
然後修改 keepfast.config.js 配置檔案,完善 repository 欄位資訊,如果你的專案是由 Vue CLI 建立和管理的,剩下的配置內容保持原樣即可。
執行效能測試並將報告輸出到 ./report.json 檔案中:
keepfast report ./report.json
上傳報告會呼叫 Gitee API,為了讓 keepfast 有許可權操作你的倉庫,你需要提供一個私人令牌,它可在設定 > 私人令牌 頁面中生成,生成後執行以下命令新增環境變數:
export GITEE_API_ACCESS_TOKEN=你的私人令牌
之後執行以下命令上傳報告:
keepfast upload ./report.json
如果當前分支已有對應的 Pull Request,則會將報告上傳到該 Pull Request 的評論中,否則上傳到當前 Commit 詳情頁的評論中。
Gitee Go 是 Gitee 推出的 CI/CD(持續構建與整合)服務,使用者可以透過自定義構建流程,實現構建整合自動化。
在你的倉庫的 master 分支上新建流水線檔案,使用如下配置:
name: keepfast displayName: keepfast triggers: push: branches: - master - develop steps: - step: npmbuild@1 name: npm-build displayName: npm-build inputs: nodeVersion: 12.7 goals: >- yum clean all yum install -y epel-release yum -y update yum install -y chromium npm config set registry https://registry.npm.taobao.org export GITEE_API_ACCESS_TOKEN=你的私人令牌 export SASS_BINARY_SITE=https://npm.taobao.org/mirrors/node-sass/ npm install npm install -g lighthouse @gitee/keepfast keepfast report ./report.json keepfast upload ./report.json
目前 Gitee Go 還不支援在網頁端設定環境變數,你需要手動將私人令牌寫到配置檔案中,但這種做法存在安全性問題,請等待 Gitee Go 的後續更新。
為什麼我要選擇 Keepfast,而不是 lighthouse-ci 等之類的工具?
如果你符合以下條件則可以試試 Keepfast。
跟 xxxx 比起來功能太少了!
如果你對效能分析這方面有不錯的想法和建議,可以反饋給我們。
[admin
]