Ash*_*ant 5 aurelia visual-studio-code
我正在尝试在VS Code中为基于Aurelia CLI的应用程序实现"F5"调试.Aurelia CLI基于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
}
]
}
Run Code Online (Sandbox Code Playgroud)
然后,当我按F5将其添加到"启动针对localhost的Chrome"调试配置时,我可以启动此任务:
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:9000",
"webRoot": "${workspaceRoot}",
"preLaunchTask": "watch"
}
Run Code Online (Sandbox Code Playgroud)
我看到的问题是,由于此任务是一项无法完成的"监视"任务,因此代码永远不会启动Chrome选项卡或启动调试会话.
我已经尝试在我的任务配置中添加了"problemMatcher",但坦率地说,此功能的文档有点稀疏.我得到的错误输出似乎与JSON模式所说的不一致.希望有人可以帮助我.这是我当前的非工作任务配置.当我说非工作时,我的意思是任务成功运行,但VS Code没有注意到任务的观看部分已经开始.
{
// 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'"
}
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
作为参考,当我运行此任务时,这是命令的输出:
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
Run Code Online (Sandbox Code Playgroud)
当我编辑并保存文件时,会在控制台输出中添加以下内容:
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'
Run Code Online (Sandbox Code Playgroud)
我们已经意识到这一点,两个相应的 GitHub 问题是:
我们计划通过两种方式改进这一点:
问题 6209 包含如何解决今天此问题的步骤,您走在正确的道路上:-)。应该有所不同的事情:
由于您不想匹配任何问题,因此请使用不匹配任何内容的正则表达式。就像是:
"pattern": {
"regexp": "__________"
}
Run Code Online (Sandbox Code Playgroud)
更大的问题是,第一次运行时,活动结束的信号与对文件更改做出反应时的信号不同。因此,endsPattern 必须同时匹配BrowserSync Available At: http://localhost:3001
和Finished 'reload'
。/(?:BrowserSync Available At:)|(?:Finished 'reload')/
所以像The beginPattern之类的正则表达式"activeOnStart": true
是正确的。
如果您仍然无法正常工作,请通过 #6209 联系我。
归档时间: |
|
查看次数: |
1018 次 |
最近记录: |