You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何无需Yeoman在VS Code Web(github.dev)中添加语言?

在github.dev中制作自定义VS Code扩展(无需Yeoman和本地客户端)

完全可以在github.dev里实现自定义扩展或个性化配置,不用依赖Yeoman或本地VS Code客户端,下面是两种可行方案:

方案一:利用.vscode文件夹实现工作区级个性化(快速简单)

如果只是需要个性化代码片段、任务、快捷键这类轻量需求,直接在仓库的.vscode文件夹下创建对应配置文件即可,无需开发正式扩展:

  • 自定义代码片段:创建.vscode/snippets/xxx.code-snippets,用JSON格式定义代码片段,保存后在github.dev中直接生效
  • 自定义任务:创建.vscode/tasks.json,配置编译、脚本运行等任务,可在github.dev的「任务」面板执行
  • 自定义快捷键:创建.vscode/keybindings.json,添加或覆盖快捷键,仅对当前工作区生效

方案二:开发正式Web扩展(功能完整)

github.dev基于VS Code Web版,支持Web Extension API,你可以手动搭建扩展结构,全程在浏览器中完成:

  1. 在GitHub上新建一个仓库,创建以下核心文件:
    • package.json:扩展配置文件,示例如下:
      {
        "name": "github-dev-custom-ext",
        "version": "0.0.1",
        "engines": {
          "vscode": "^1.80.0"
        },
        "main": "./extension.js",
        "contributes": {
          "commands": [
            {
              "command": "my-ext.hello",
              "title": "Hello from My Extension"
            }
          ]
        }
      }
      
    • extension.js:扩展主逻辑,使用VS Code Web API,示例如下:
      const vscode = require('vscode');
      
      function activate(context) {
        const helloCmd = vscode.commands.registerCommand('my-ext.hello', () => {
          vscode.window.showInformationMessage('Hello from your github.dev extension!');
        });
        context.subscriptions.push(helloCmd);
      }
      
      function deactivate() {}
      
      module.exports = { activate, deactivate };
      
  2. 在github.dev中打开这个仓库,按F1执行Developer: Install Extension from Location,选择当前仓库的根目录,即可加载扩展
  3. 测试扩展:按F1搜索你定义的Hello from My Extension命令,运行即可看到提示

注意:Web扩展仅支持VS Code的Web兼容API,部分Node.js专属API无法使用,但常用的命令、弹窗、编辑器操作等API都能正常工作。

内容的提问来源于stack exchange,提问作者AdamRaichu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.15 23:55:23