1. 性能优化设置
// settings.json
{
"files.autoSave": "afterDelay", // 自动保存(延迟1秒)
"files.exclude": { // 隐藏非必要文件
"**/.git": true,
"**/.DS_Store": true,
"**/node_modules": true // 大型项目建议保留但折叠
},
"search.followSymlinks": false, // 加速全局搜索
"editor.tabSize": 2, // 统一缩进为2空格(前端规范)
"editor.codeActionsOnSave": { // 保存时自动修复
"source.fixAll.eslint": true
}
}
2. 必装核心插件
插件名称 | 用途 | 推荐配置 |
---|---|---|
ESLint | JavaScript/TS 代码规范检查 | 搭配Airbnb/Standard规则集 |
Prettier | 代码自动格式化 | 设置为首选格式化器 |
Vetur | Vue 开发支持(语法高亮、SFC拆分) | 开启模板插值验证 |
Live Server | HTML 实时热更新 | 右键启动项目 |
Auto Rename Tag | 自动重命名HTML/XML标签 | 默认启用 |
1. 主题推荐
2. 图标与布局
{
"workbench.iconTheme": "material-icon-theme", // 图标主题
"editor.minimap.enabled": false, // 关闭缩略图(提升性能)
"breadcrumbs.enabled": true, // 显示路径导航
"editor.fontFamily": "Fira Code", // 编程连字字体
"editor.fontLigatures": true // 启用连字符
}
3. 沉浸式编码
1. Vue 3 高效开发配置
{
"vetur.format.defaultFormatter.html": "prettier",
"vetur.experimental.templateInterpolationService": true, // 模板类型检查
"emmet.includeLanguages": { // Vue模板支持Emmet
"vue-html": "html"
}
}
2. CSS/SCSS 智能工具链
.vscode/tasks.json
):{
"version": "2.0.0",
"tasks": [{
"label": "Watch Sass",
"type": "npm",
"script": "watch-sass", // 需提前配置package.json脚本
"isBackground": true
}]
}
3. 代码片段加速开发
v3
生成Vue3基础模板// html.json
{
"快速生成HTML5结构": {
"prefix": "html5",
"body": [
"",
"",
"",
" ",
" $1 ",
"",
"",
" $0",
"",
""
]
}
}
1. Chrome 调试配置
// launch.json
{
"version": "0.2.0",
"configurations": [{
"type": "chrome",
"request": "launch",
"name": "Vue调试",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}/src",
"breakOnLoad": true,
"sourceMapPathOverrides": {
"webpack:///src/*": "${webRoot}/*"
}
}]
}
2. 终端集成
# 在$PROFILE中添加
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\atomic.omp.json" | Invoke-Expression
1. 统一团队规范
settings.json
关键配置:{
"editor.formatOnSave": true,
"eslint.validate": ["javascript", "vue"],
"prettier.singleQuote": true,
"typescript.preferences.importModuleSpecifier": "relative"
}
2. 配置同步方案
.devcontainer
定义标准化开发环境工具类型 | 推荐插件 | 核心功能 |
---|---|---|
代码质量 | SonarLint | 实时检测代码异味 |
API调试 | REST Client | 直接编写HTTP请求测试 |
数据库 | SQLTools | 连接MySQL/PostgreSQL |
可视化 | Draw.io Integration | 在VSCode内绘制架构图 |
AI辅助 | GitHub Copilot | 智能代码补全(需订阅) |
注意事项
%USER%\.vscode\extensions
文件夹"typescript.tsserver.watchOptions": {}
调整)最终效果预览
立即应用这些配置,让你的VSCode成为前端开发的超级武器!
(附配置包下载链接:https://github.com/example/vscode-frontend-preset)