VS Code Workspace Configuration - Complete Guide
Published: September 25, 2024 | Reading time: 12 minutes
Quick Workspace Setup
Set up a professional workspace configuration in minutes:
Essential Files
.vscode/
├── settings.json # Project settings
├── tasks.json # Build tasks
├── launch.json # Debug configurations
└── extensions.json # Recommended extensions
# Create workspace
File → Save Workspace As → my-project.code-workspace
Understanding VS Code Workspaces
VS Code workspaces provide:
- Project organization - Group related files and folders
- Settings isolation - Project-specific configurations
- Task automation - Build, test, and deploy tasks
- Debug configurations - Launch and debug settings
- Extension management - Project-specific extensions
Workspace Types
Single Folder Workspace
The simplest workspace type - a single project folder:
Single Folder Structure
my-project/
├── src/
├── public/
├── package.json
├── .vscode/
│ ├── settings.json
│ ├── tasks.json
│ └── launch.json
└── README.md
Multi-root Workspace
Combine multiple projects in a single workspace:
Multi-root Structure
fullstack-project/
├── frontend/ # React app
├── backend/ # Node.js API
├── shared/ # Shared utilities
├── docs/ # Documentation
└── fullstack.code-workspace
Workspace Configuration Files
settings.json - Project Settings
Project Settings
{
// Editor settings
"editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.organizeImports": true
},
// File associations
"files.associations": {
"*.tsx": "typescriptreact",
"*.jsx": "javascriptreact"
},
// Language-specific settings
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
// Exclude files
"files.exclude": {
"**/node_modules": true,
"**/dist": true,
"**/.git": true
}
}
tasks.json - Build Tasks
Build Tasks
{
"version": "2.0.0",
"tasks": [
{
"label": "npm install",
"type": "shell",
"command": "npm install",
"group": "build",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "new"
}
},
{
"label": "npm run build",
"type": "shell",
"command": "npm run build",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
},
"problemMatcher": ["$tsc"]
},
{
"label": "npm test",
"type": "shell",
"command": "npm test",
"group": "test",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
}
}
]
}
launch.json - Debug Configurations
Debug Configurations
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Chrome",
"type": "chrome",
"request": "launch",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}/src",
"sourceMaps": true
},
{
"name": "Launch Node.js",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/server.js",
"env": {
"NODE_ENV": "development"
},
"console": "integratedTerminal"
},
{
"name": "Attach to Node",
"type": "node",
"request": "attach",
"port": 9229,
"restart": true
}
],
"compounds": [
{
"name": "Launch Full Stack",
"configurations": ["Launch Chrome", "Launch Node.js"],
"stopAll": true
}
]
}
extensions.json - Recommended Extensions
Extension Recommendations
{
"recommendations": [
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint",
"ms-vscode.vscode-typescript-next",
"bradlc.vscode-tailwindcss",
"ms-vscode.vscode-json",
"formulahendry.auto-rename-tag",
"christian-kohler.path-intellisense",
"ms-vscode.vscode-css-peek"
],
"unwantedRecommendations": [
"ms-vscode.vscode-typescript"
]
}
Multi-root Workspace Configuration
Creating Multi-root Workspaces
Multi-root Workspace File
{
"folders": [
{
"name": "Frontend",
"path": "./frontend"
},
{
"name": "Backend",
"path": "./backend"
},
{
"name": "Shared",
"path": "./shared"
},
{
"name": "Documentation",
"path": "./docs"
}
],
"settings": {
"typescript.preferences.includePackageJsonAutoImports": "auto",
"editor.formatOnSave": true,
"files.exclude": {
"**/node_modules": true,
"**/dist": true
}
},
"extensions": {
"recommendations": [
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint"
]
},
"launch": {
"version": "0.2.0",
"configurations": [
{
"name": "Launch Frontend",
"type": "chrome",
"request": "launch",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder:Frontend}/src"
},
{
"name": "Launch Backend",
"type": "node",
"request": "launch",
"program": "${workspaceFolder:Backend}/server.js"
}
]
}
}
Advanced Workspace Features
Workspace-specific Tasks
Complex Task Configuration
{
"version": "2.0.0",
"tasks": [
{
"label": "Build All Projects",
"dependsOrder": "sequence",
"dependsOn": [
"Build Frontend",
"Build Backend"
]
},
{
"label": "Build Frontend",
"type": "shell",
"command": "npm run build",
"options": {
"cwd": "${workspaceFolder:Frontend}"
},
"group": "build"
},
{
"label": "Build Backend",
"type": "shell",
"command": "npm run build",
"options": {
"cwd": "${workspaceFolder:Backend}"
},
"group": "build"
},
{
"label": "Watch All",
"dependsOrder": "parallel",
"dependsOn": [
"Watch Frontend",
"Watch Backend"
],
"isBackground": true
}
]
}
Environment-specific Configurations
Environment Configurations
{
"version": "0.2.0",
"configurations": [
{
"name": "Development",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/server.js",
"env": {
"NODE_ENV": "development",
"PORT": "3000",
"DB_URL": "mongodb://localhost:27017/dev"
}
},
{
"name": "Testing",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/server.js",
"env": {
"NODE_ENV": "test",
"PORT": "3001",
"DB_URL": "mongodb://localhost:27017/test"
}
},
{
"name": "Production",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/server.js",
"env": {
"NODE_ENV": "production",
"PORT": "8080",
"DB_URL": "${env:PROD_DB_URL}"
}
}
]
}
Workspace Management
Opening and Saving Workspaces
Workspace Commands
// Open workspace
File → Open Workspace from File
Ctrl+Shift+P → "Workspaces: Open Workspace"
// Save workspace
File → Save Workspace As
Ctrl+Shift+P → "Workspaces: Save Workspace As"
// Recent workspaces
File → Open Recent
Ctrl+R - Open recent workspace
// Workspace management
Ctrl+Shift+P → "Workspaces: Duplicate Workspace"
Ctrl+Shift+P → "Workspaces: Close Workspace"
Workspace Settings Hierarchy
Settings Priority
Settings Priority (highest to lowest):
1. Workspace settings (.vscode/settings.json)
2. Multi-root workspace settings
3. User settings (settings.json)
4. Default settings
// Check current settings
Ctrl+Shift+P → "Preferences: Open Settings (UI)"
Click "Workspace" tab to see workspace-specific settings
Workspace Best Practices
Organization Tips
Structure Tips
- Use descriptive folder names
- Keep related projects together
- Use consistent naming conventions
- Document workspace purpose
Configuration Tips
- Use workspace-specific settings
- Configure tasks for common operations
- Set up proper debug configurations
- Recommend essential extensions
Performance Optimization
Performance Settings
{
// Exclude large directories
"files.exclude": {
"**/node_modules": true,
"**/dist": true,
"**/build": true,
"**/.git": true,
"**/coverage": true
},
// Limit file watchers
"files.watcherExclude": {
"**/node_modules/**": true,
"**/dist/**": true
},
// Search exclusions
"search.exclude": {
"**/node_modules": true,
"**/dist": true,
"**/coverage": true
}
}
Team Collaboration
Sharing Workspace Configurations
Team Setup
// .vscode/settings.json (shared)
{
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"typescript.preferences.includePackageJsonAutoImports": "auto"
}
// .vscode/extensions.json (shared)
{
"recommendations": [
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint"
]
}
// .gitignore (exclude personal settings)
.vscode/settings.json
!.vscode/settings.json.example
Summary
VS Code workspace configuration provides powerful project management:
- Single vs Multi-root: Choose the right workspace type
- Configuration files: settings.json, tasks.json, launch.json, extensions.json
- Task automation: Build, test, and deploy workflows
- Debug configurations: Environment-specific debugging
- Team collaboration: Shared workspace configurations
Need More Help?
Need help setting up complex workspace configurations or want to optimize your development workflow? Our workspace experts can help you create the perfect project setup.
Get Workspace Help