parcel 开发 vscode 插件

好久不见. 提交于 2020-08-14 13:18:56

安装

yarn  add parcel-bundler parcel-plugin-externals

package.json

忽视vscode, 添加watch

  "externals": [
    "vscode"
  ],
  "scripts": {
    "lint": "eslint .",
    "pretest": "yarn run lint",
    "test": "node ./test/runTest.js",
    "watch": "parcel   ./src/extension.js -d dist  --target node",
    "build": "parcel build  ./src/extension.js -d dist  --target node"
  },

Launch.json

// A launch configuration that launches the extension inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
	"version": "0.2.0",
	"configurations": [
		
		{
			"name": "Run Extension",
			"type": "extensionHost",
			"request": "launch",
			"runtimeExecutable": "${execPath}",
			"args": [
				"--extensionDevelopmentPath=${workspaceFolder}"
			],
			"outFiles": [
				"${workspaceFolder}/dist/**/*.js"
			],
			"preLaunchTask": "${defaultBuildTask}"
		},
		{
			"name": "Extension Tests",
			"type": "extensionHost",
			"request": "launch",
			"runtimeExecutable": "${execPath}",
			"args": [
				"--extensionDevelopmentPath=${workspaceFolder}",
				"--extensionTestsPath=${workspaceFolder}/test/suite/index"
			],
			"outFiles": [
				"${workspaceFolder}/dist/test/**/*.js"
			],
			"preLaunchTask": "${defaultBuildTask}"
		}
	]
}

 

tasks.json

// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
{
	"version": "2.0.0",
	"tasks": [
		{
			"type": "npm",
			"script": "watch",
			// "problemMatcher": "$tsc-watch",
			"isBackground": true,
			"presentation": {
				"reveal": "never"
			},
			"group": {
				"kind": "build",
				"isDefault": true
			}
		}
	]
}

 

命令行使用

npm run watch

这样在修改代码后在新窗口中使用ctrl+r就能看到更新后的效果了

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!