feat(vscode): 增强开发调试配置支持
Some checks failed
/ build-and-test (push) Failing after 1m24s
/ playwright (push) Successful in 1m46s
CI/CD Pipeline / build-and-deploy (push) Failing after 2m2s
CI/CD Pipeline / playwright (push) Successful in 4m5s

This commit is contained in:
严浩
2025-10-16 16:37:40 +08:00
parent 4e31d8b80c
commit 7b6f7ad2fb
8 changed files with 129 additions and 57 deletions

13
.vscode/launch.json vendored
View File

@@ -8,7 +8,18 @@
"url": "http://localhost:4730/", "url": "http://localhost:4730/",
"webRoot": "${workspaceFolder}", "webRoot": "${workspaceFolder}",
"firefoxExecutable": "/Applications/Firefox Nightly.app/Contents/MacOS/firefox", "firefoxExecutable": "/Applications/Firefox Nightly.app/Contents/MacOS/firefox",
"preLaunchTask": "🚀 dev" "preLaunchTask": "🚀 dev",
"pathMappings": [
{
"url": "http://localhost:4730",
"path": "${workspaceFolder}"
}
],
"reAttach": true,
"reloadOnChange": {
"watch": "${workspaceFolder}/src/**/*.{js,jsx,ts,tsx,vue}",
"ignore": "**/node_modules/**"
}
} }
] ]
} }

54
.vscode/tasks.json vendored
View File

@@ -2,32 +2,48 @@
"version": "2.0.0", "version": "2.0.0",
"tasks": [ "tasks": [
{ {
"type": "npm",
"script": "dev",
"label": "🚀 dev", "label": "🚀 dev",
"type": "shell", "detail": "启动开发服务器",
"command": "pnpm run dev",
"isBackground": true,
"problemMatcher": { "problemMatcher": {
"owner": "vite", "pattern": { "regexp": "." },
"pattern": {
"regexp": "."
},
"background": { "background": {
"activeOnStart": true, "activeOnStart": true,
"beginsPattern": ".*VITE.*", "beginsPattern": "VITE.*ready in",
"endsPattern": ".*ready in.*" "endsPattern": "(Local|Network):.*http"
} }
}, },
"group": { "isBackground": true,
"kind": "build", "presentation": { "reveal": "always", "panel": "dedicated" },
"isDefault": true "group": { "kind": "build", "isDefault": false }
},
{
"type": "npm",
"script": "build-only",
"label": "🔨 build-only",
"detail": "" /* VSCode 使 package.json scripts[scriptName] detail */,
"problemMatcher": ["$tsc"],
"presentation": { "reveal": "always", "panel": "shared" },
"group": { "kind": "none", "isDefault": false }
},
{
"type": "npm",
"script": "wrangler:dev",
"label": "☁️ wrangler:dev",
"detail": "启动 Cloudflare Workers 开发服务器,相当于预览",
"dependsOn": ["🔨 build-only"],
"problemMatcher": {
"pattern": { "regexp": "." },
"background": {
"activeOnStart": true,
"beginsPattern": "wrangler dev",
"endsPattern": "Ready on"
}
}, },
"presentation": { "isBackground": true,
"reveal": "always", "presentation": { "reveal": "always", "panel": "dedicated" },
"panel": "new" "group": { "kind": "build", "isDefault": false }
},
"runOptions": {
"instanceLimit": 1
}
} }
] ]
} }

73
README-command.md Normal file
View File

@@ -0,0 +1,73 @@
## 依赖管理
```shell
pnpm dedupe
```
去除重复的依赖包。当你的项目中存在多个版本的同一个包时pnpm dedupe 会尝试将它们合并成尽可能少的版本,从而减少 node_modules 的体积。
```bash
pnpm dlx taze major --interactive
```
交互式地将项目依赖升级到最新的主要版本,可以逐个选择要升级哪些包。
```bash
pnpm dlx knip
```
检测项目中未使用的依赖、导出和文件,帮助清理冗余代码。
## Playwright
```bash
playwright test
```
- `HEADLESS=true`:强制无头模式
- `--ui`:启动 Playwright 的图形用户界面,方便调试测试用例
- `--project=chromium`:指定使用 Chromium 浏览器进行测试
- `--quiet`:减少输出信息,只显示必要的内容
## Oxlint
```bash
oxlint . --fix --ignore-path=.gitignore --print-config
```
```bash
oxlint . --fix --deny=correctness
```
## Wrangler
### Pages
```bash
wrangler pages deploy dist --project-name=vue-ts-example-2025 --branch=preview
```
```bash
wrangler pages deploy dist --project-name=vue-ts-example-2025
```
### Workers
```bash
wrangler deploy
```
```bash
wrangler versions upload
```
## 拆包体积分析
- https://github.com/nonzzz/vite-bundle-analyzer
- https://github.com/KusStar/vite-bundle-visualizer
```bash
pnpm dlx vite-bundle-visualizer -t treemap
pnpm dlx vite-bundle-visualizer -t sunburst
pnpm dlx vite-bundle-visualizer -t network
```

View File

@@ -8,41 +8,21 @@
"node": "^20.19.0 || >=22.12.0" "node": "^20.19.0 || >=22.12.0"
}, },
"scripts": { "scripts": {
"_all": "run-p build-only format type-check lint", "_all": "run-p build-only format:prettier type-check lint test:unit:DisableWatch",
"dev": "vite --port 4730 --host --strictPort", "dev": "vite --port 4730 --host --strictPort",
"build": "run-p type-check \"build-only {@}\" --", "build": "run-p type-check \"build-only {@}\" --",
"build-only": "vite build", "build-only": "vite build",
"preview": "vite preview", "preview": "vite preview --port 4731 --host --strictPort",
"preview:wrangler": "run-s build-only wrangler:dev", "wrangler:dev": "wrangler dev --port 4732",
"wrangler:dev": "wrangler dev", "format:prettier": "prettier --write src/",
"lint": "run-s lint:*",
"format": "prettier --write src/",
"type-check": "vue-tsc --build", "type-check": "vue-tsc --build",
"lint": "run-s lint:*",
"lint:stylelint": "stylelint \"**/*.{css,less,scss,vue}\" --fix --ignore-path .gitignore", "lint:stylelint": "stylelint \"**/*.{css,less,scss,vue}\" --fix --ignore-path .gitignore",
"lint:oxlint": "oxlint . --fix -D correctness --ignore-path .gitignore", "lint:oxlint": "oxlint . --fix -D correctness --ignore-path .gitignore",
"lint:eslint": "eslint . --fix", "lint:eslint": "eslint . --fix",
"test:unit": "vitest",
"test:unit:DisableWatch": "vitest --run", "test:unit:DisableWatch": "vitest --run",
"test:playwright": "playwright test", "test:playwright:headless": "HEADLESS=true playwright test --quiet",
"test:playwright:headless": "HEADLESS=true playwright test",
"test:playwright:ui": "playwright test --ui",
"test:playwright:chromium": "playwright test --project=chromium --quiet",
"_oxlint_cfg": "oxlint . --fix --ignore-path=.gitignore --print-config",
"__oxlint_-D": "oxlint . --fix --deny=correctness",
"-wrangler:pages:deploy:preview": "wrangler pages deploy dist --project-name=vue-ts-example-2025 --branch=preview",
"-wrangler:pages:deploy:prod": "wrangler pages deploy dist --project-name=vue-ts-example-2025",
"-deploy:preview": "run-s build-only wrangler:pages:deploy:preview",
"-deploy:prod": "run-s build-only wrangler:pages:deploy:prod",
"wrangler:deploy": "pnpm run build && wrangler deploy",
"wrangler:versions:upload": "pnpm run build && wrangler versions upload",
"cf-typegen": "wrangler types",
"postinstall": "wrangler types", "postinstall": "wrangler types",
"_dep:dedupe": "pnpm dedupe",
"_dep:update": "pnpm dlx taze major --interactive",
"_sizecheck:Treemap": "pnpm dlx vite-bundle-visualizer -t treemap",
"_sizecheck:Sunburst": "pnpm dlx vite-bundle-visualizer -t sunburst",
"_sizecheck:Network": "pnpm dlx vite-bundle-visualizer -t network",
"_knip": "pnpm dlx knip",
"prepare": "husky" "prepare": "husky"
}, },
"lint-staged": { "lint-staged": {
@@ -108,7 +88,6 @@
"happy-dom": "^20.0.1", "happy-dom": "^20.0.1",
"html-minifier-terser": "^7.2.0", "html-minifier-terser": "^7.2.0",
"husky": "^9.1.7", "husky": "^9.1.7",
"jiti": "^2.5.1",
"jsdom": "^27.0.0", "jsdom": "^27.0.0",
"lint-staged": "^16.1.6", "lint-staged": "^16.1.6",
"npm-run-all2": "^8.0.4", "npm-run-all2": "^8.0.4",

View File

@@ -2,7 +2,7 @@ import { defineConfig, devices } from '@playwright/test';
import process from 'node:process'; import process from 'node:process';
// const runningInVSCode = process.env.TERM_PROGRAM === 'vscode' // const runningInVSCode = process.env.TERM_PROGRAM === 'vscode'
const baseURL = 'http://localhost:4173'; const baseURL = 'http://localhost:4731';
/** /**
* Read environment variables from file. * Read environment variables from file.

3
pnpm-lock.yaml generated
View File

@@ -147,9 +147,6 @@ importers:
husky: husky:
specifier: ^9.1.7 specifier: ^9.1.7
version: 9.1.7 version: 9.1.7
jiti:
specifier: ^2.5.1
version: 2.6.1
jsdom: jsdom:
specifier: ^27.0.0 specifier: ^27.0.0
version: 27.0.0(postcss@8.5.6) version: 27.0.0(postcss@8.5.6)

View File

@@ -73,6 +73,7 @@ export default defineConfig(({ command, mode }) => {
}, },
}, },
css: { css: {
devSourcemap: true,
preprocessorOptions: { preprocessorOptions: {
scss: { scss: {
// 使用 Sass 的现代编译器 API提供更好的性能和新功能支持 // 使用 Sass 的现代编译器 API提供更好的性能和新功能支持

View File

@@ -1,5 +1,5 @@
/* eslint-disable */ /* eslint-disable */
// Generated by Wrangler by running `wrangler types` (hash: c8d566f9236103c3d936718f23f1bb71) // Generated by Wrangler by running `wrangler types` (hash: 7094267439eea3789640d49ba1e25377)
// Runtime types generated with workerd@1.20250927.0 2025-09-09 // Runtime types generated with workerd@1.20250927.0 2025-09-09
declare namespace Cloudflare { declare namespace Cloudflare {
interface GlobalProps { interface GlobalProps {
@@ -7,11 +7,6 @@ declare namespace Cloudflare {
} }
interface Env { interface Env {
KV: KVNamespace; KV: KVNamespace;
VITE_APP_TITLE: string;
VITE_APP_BASE: string;
VITE_APP_BUILD_SOURCE_MAP: string;
VITE_APP_BUILD_COMMIT: string;
VITE_APP_BUILD_TIME: string;
} }
} }
interface Env extends Cloudflare.Env {} interface Env extends Cloudflare.Env {}