开发环境准备
- VSCode
- Nodejs
- 官方推荐使用的脚手架工具 Yeoman 和 Generator-code
- 插件打包和发布工具 vsce
脚手架使用
1、安装
npm install -g yo generator-code
2、使用脚手架
3、执行
Inside the editor, open src/extension.ts
and pressF5
. This will compile and run the extension in a new Extension Development Host window.
Run the Hello World command from the Command Palette (Ctrl+Shift+P)
in the new window:
发布
发布插件的方式基本有三种:
1、直接共享源文件;
2、发布到插件市场;
3、使用vsce,打包成vsix插件安装。
npm install -g @vscode/vsce
vsce publish
配置
activationEvents
onLanguage
当打开为特定语言的文件时, 插件被激活。
"activationEvents": [
"onLanguage:typescript",
"onLanguage:typescriptreact"
]