作者:Jason | 来源:互联网 | 2023-09-09 15:54
安装yarnaddparcel-bundlerparcel-plugin-externalspackage.json忽视vscode,添加watch"externals&
![parcel 开发 vscode 插件](https://img1.php1.cn/3cd4a/25047/b64/098740bf3c80ead1.jpeg)
安装
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就能看到更新后的效果了