Files
vue-ts-example-2025/.devcontainer/devcontainer.json
严浩 e6731afff5
All checks were successful
CI/CD Pipeline / playwright (push) Successful in 1m33s
CI/CD Pipeline / build-and-deploy (push) Successful in 1m53s
测试最新依赖 / build-and-test (push) Successful in 1m31s
测试最新依赖 / playwright (push) Successful in 2m26s
chore: update devcontainer configuration and add setup scripts
2025-11-18 00:47:42 +08:00

143 lines
5.5 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
"image": "ghcr.io/yanhao98/h-devcontainer:oncreatecommand.d",
"runArgs": ["--name=${localWorkspaceFolderBasename}-devcontainer"],
"forwardPorts": [4730, 4731], // vscode://settings/remote.localPortHost -> 默认只监听 localhost
"portsAttributes": {
"4730": { "label": "开发服务器端口", "onAutoForward": "notify" },
"4731": { "label": "预览服务器端口", "onAutoForward": "notify" }
},
"remoteEnv": {
"ANTHROPIC_AUTH_TOKEN": "${localEnv:ANTHROPIC_AUTH_TOKEN}",
"ANTHROPIC_BASE_URL": "${localEnv:ANTHROPIC_BASE_URL}",
"GEMINI_API_KEY": "${localEnv:GEMINI_API_KEY}",
"GOOGLE_GEMINI_BASE_URL": "${localEnv:GOOGLE_GEMINI_BASE_URL}",
"PATH": "${containerEnv:PATH}:${containerWorkspaceFolder}/node_modules/.bin:${containerEnv:HOME}/.bun/bin:${containerEnv:HOME}/.bun/bin/bun-node-fallback-bin"
},
"containerEnv": {
"HOME": "/home/usr_vscode",
// "NODE_OPTIONS": "--max-old-space-size=4096",
"TZ": "${localEnv:TZ:Asia/Shanghai}"
},
"customizations": {
"vscode": {
"extensions": [
// AI
"github.copilot-chat",
"anthropic.claude-code",
"google.gemini-cli-vscode-ide-companion",
"vicanent.gcmp",
// >>>>>
// "eamodio.gitlens",
"tu6ge.naive-ui-intelligence",
"gruntfuggly.todo-tree",
"lokalise.i18n-ally",
"vitest.explorer",
"antfu.unocss",
"vue.volar",
// <<<<<
// 代码质量 / 格式化 / Lint
"dbaeumer.vscode-eslint",
"stylelint.vscode-stylelint",
"oxc.oxc-vscode",
"esbenp.prettier-vscode"
],
"settings": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"chat.extensionUnification.enabled": true,
"chat.tools.terminal.autoApprove": {
"/.*/": true,
"git push": false
},
// * 尽管使用了“/.*/”,但有些还是会失败,因为有几个错误的默认值:
// * https://github.com/microsoft/vscode/issues/266651#issuecomment-3292581459
"chat.tools.terminal.ignoreDefaultAutoApproveRules": true,
"tasks": {
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "dev",
"label": "🚀 Dev: Run on Folder Open",
"runOptions": {
"runOn": "folderOpen"
},
"isBackground": true,
"presentation": {
"panel": "dedicated"
}
}
]
},
// https://stackoverflow.com/questions/75708866/vscode-dev-container-fails-to-load-ms-vscode-js-debug-extension-correctly
// https://davidwesst.com/blog/missing-bootloader-in-vscode-devcontainer/
/**
* autoAttachFilter NODE_OPTIONS bootloader.js --require
* --max-old-space-size
* NODE_OPTIONS= --require /home/.../bootloader.js --max-old-space-size=4096--max-old-space-size=4096
*
* Error: illegal value for flag --max-old-space-size=4096--max-old-space-size=4096 of type size_t
* "disabled"
*/
// "debug.javascript.autoAttachFilter": "disabled",
"terminal.integrated.defaultProfile.linux": "💲zsh",
"terminal.integrated.profiles.linux": {
"💲zsh": {
"path": "zsh",
"icon": "terminal-cmd",
"overrideName": true,
"color": "terminal.ansiGreen"
}
}
}
}
},
"mounts": [
{
// 不挂载可能会遇到:`Cannot run macOS (Mach-O) executable in Docker: Exec format error`
"type": "volume",
"source": "${localWorkspaceFolderBasename}-node_modules",
"target": "${containerWorkspaceFolder}/node_modules"
},
{
"type": "volume",
"source": "devcontainer-pnpm-store",
"target": "/home/usr_vscode/.pnpm-store"
},
{
"type": "volume",
"source": "devcontainer-bun-install-cache",
"target": "/home/usr_vscode/.bun/install/cache"
// rm -rf ~/.bun/install/cache/*
},
{
"type": "bind",
"source": "${localWorkspaceFolder}/.devcontainer/onCreateCommand.d",
"target": "/usr/local/etc/onCreateCommand.d"
}
],
/**
*
1. initializeCommand ()
2.
3. onCreateCommand ()
4. updateContentCommand ()
5. postCreateCommand ()
6.
7. postStartCommand ()
8. VS Code
9. postAttachCommand ()
*/
"initializeCommand": "echo '↘️ 准备创建容器...'; docker pull ghcr.io/yanhao98/h-devcontainer:oncreatecommand.d;",
"onCreateCommand": "echo '↘️ 容器首次创建!'; /usr/local/bin/onCreateCommand.sh",
"updateContentCommand": "echo '↘️ 容器内容已更新!'; zsh -c 'time pnpm install;'",
"postCreateCommand": "echo '↘️ 容器已创建!';",
"postStartCommand": "echo '↘️ 容器启动了!'",
"postAttachCommand": "echo '↘️ VS Code 已附加到容器!'; zsh -c 'source ~/.zshrc; echo \"$(date +%Y-%m-%dT%H:%M:%S%z) - Welcome to your Dev Container!\"';",
"waitFor": "updateContentCommand",
"remoteUser": "usr_vscode"
}