我试图在VS代码中为基于Aurelia的应用程序实现"F5“调试。Aurelia是建立在Gulp任务之上的。我希望设置一个运行au run --watch的任务,并在按"F5“进行调试时启动该任务(”启动Chrome“选项)。
为au run --watch命令创建一个基本任务非常简单。
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "au",
"isShellCommand": true,
"tasks": [
{
"taskName": "watch",
"suppressTaskName": true,
"args": [
"run",
"--watch"
],
"isBuildCommand": false,
"isBackground": true
}
]
}然后,通过将F5添加到“针对本地主机的启动”调试配置中,可以在按下F5时启动该任务:
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:9000",
"webRoot": "${workspaceRoot}",
"preLaunchTask": "watch"
}我看到的问题是,因为这个任务是一个“监视”任务,还没有完成,所以代码从不启动Chrome选项卡或启动调试会话。
我尝试在任务配置中添加一个"problemMatcher“,但坦率地说,这个特性的文档有点稀疏。我得到的错误输出似乎与JSON模式的内容不匹配。希望有人能帮我个忙。以下是我当前的非工作任务配置。当我说“不工作”时,我的意思是任务成功运行,但是VS代码没有注意到任务的监视部分已经开始。
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "au",
"isShellCommand": true,
"tasks": [
{
"taskName": "watch",
"suppressTaskName": true,
"args": [
"run",
"--watch"
],
"isBuildCommand": false,
"isBackground": true,
"problemMatcher": {
"owner": "au",
"severity": "info",
"fileLocation": [
"relative",
"${workspaceRoot}"
],
"pattern": {
"regexp": "^BrowserSync Available At: http://localhost:3001$",
"file": 1
},
"watching": {
"activeOnStart": true,
"beginsPattern": "^File Changed: (.*)",
"endsPattern": "^Finished 'reload'"
}
}
}
]
}作为参考,当我运行此任务时,这是命令的输出:
Starting 'readProjectConfiguration'...
Finished 'readProjectConfiguration'
Starting 'processMarkup'...
Starting 'processCSS'...
Starting 'copyFiles'...
Starting 'configureEnvironment'...
Finished 'copyFiles'
Finished 'processCSS'
Finished 'processMarkup'
Finished 'configureEnvironment'
Starting 'buildJavaScript'...
Finished 'buildJavaScript'
Starting 'writeBundles'...
Tracing app...
Tracing environment...
Tracing main...
Tracing resources/index...
Tracing app...
Tracing aurelia-binding...
Tracing aurelia-bootstrapper...
Tracing aurelia-dependency-injection...
Tracing aurelia-event-aggregator...
Tracing aurelia-framework...
Tracing aurelia-history...
Tracing aurelia-history-browser...
Tracing aurelia-loader-default...
Tracing aurelia-logging-console...
Tracing aurelia-pal-browser...
Tracing aurelia-route-recognizer...
Tracing aurelia-router...
Tracing aurelia-templating-binding...
Tracing text...
Tracing aurelia-templating-resources...
Tracing aurelia-templating-router...
Tracing aurelia-testing...
Writing app-bundle.js...
Writing vendor-bundle.js...
Finished 'writeBundles'
Application Available At: http://localhost:9000
BrowserSync Available At: http://localhost:3001在编辑和保存文件时,控制台输出中添加了如下内容:
File Changed: src\app.js
Starting 'readProjectConfiguration'...
Finished 'readProjectConfiguration'
Starting 'processMarkup'...
Starting 'processCSS'...
Starting 'copyFiles'...
Starting 'configureEnvironment'...
Finished 'copyFiles'
Finished 'processCSS'
Finished 'processMarkup'
Finished 'configureEnvironment'
Starting 'buildJavaScript'...
Finished 'buildJavaScript'
Starting 'writeBundles'...
Tracing app...
Writing app-bundle.js...
Finished 'writeBundles'
Starting 'reload'...
Finished 'reload'发布于 2017-04-13 09:23:06
我们意识到这一点,相应的两个GitHub问题是:
我们计划通过两种方式改善这一状况:
问题6209包含了如何在今天解决这个问题的步骤,您在正确的路径上:-)。应该是不同的东西:
因为您不想匹配任何问题,所以使用一个不匹配任何问题的regexp。类似于:
"pattern": {
"regexp": "__________"
}更大的问题是,在第一次运行时,活动结束的信号是不同的,然后在响应文件更改时发出不同的信号。因此,endsPattern必须同时匹配BrowserSync Available At: http://localhost:3001和Finished 'reload'。因此,像/(?:BrowserSync Available At:)|(?:Finished 'reload')/、beginsPattern和"activeOnStart": true这样的regexp是正确的。
如果你还不让它开始工作,请给我打电话6209。
https://stackoverflow.com/questions/43379296
复制相似问题