2017-03-19 61 views
0

我想找到一种方法来从Visual Studio代码而不是从Chrome调试我的本地SPFx工作台,但我找不到任何有关如何将Chrome附加到Visual工作室代码,并在我的反应打字稿webpart(网络应用程序)中打断点。有没有什么好的指导如何做到这一点?SPFx断点和调试从Visual Studio代码而不是从Chrome

这可能是微不足道的,但我对react-gulp-vs代码世界很陌生,在过去,使用Visual Studio和IExplorer调试javascript相对容易,我想知道如果Visual Studio Code也是如此。

谢谢!

回答

0

在这个快速更新。 @gruss对于Chrome的调试器是正确的,但我想更进一步,并创建一个指南。

从Office开发团队这里的官方文件: https://dev.office.com/sharepoint/docs/spfx/debug-in-vscode

我发现非常有用的文章在这里: http://www.eliostruyf.com/how-to-debug-your-sharepoint-framework-web-part

我还创建了一个位置: http://blog.velingeorgiev.pro/how-debug-sharepoint-framework-webpart-visual-studio-code

吉斯特一起推出。 json config here: https://gist.github.com/VelinGeorgiev/4a7b77ced7198df0a3898420d46f3405

此处粘贴的配置可供快速参考:

// Use Chrome browser to debug SharePoint Framework React webpart with Visual Studio Code on Windows 
// - Install "Debugger for Chrome" extension 
// - Add this configuration to the launch.json 
// - Close all Chrome browser active instances 
// - Start the SPFx nodejs server by executing "gulp serve" 
// - Go to VS Code debug view (top menu -> View -> Debug) 
// - Hit the play (start debugging) button 
// Happy debugging! 
// Full guides 
// http://blog.velingeorgiev.pro/how-debug-sharepoint-framework-webpart-visual-studio-code 
// https://dev.office.com/sharepoint/docs/spfx/debug-in-vscode 
{ 
    "version": "0.2.0", 
    "configurations": [ 
     { 
      "name": "SPFx Local", 
      "type": "chrome", 
      "request": "launch", 
      "url": "https://localhost:4321/temp/workbench.html", 
      "webRoot": "${workspaceRoot}", 
      "sourceMaps": true, 
      "sourceMapPathOverrides": { 
       "webpack:///../../../src/*": "${webRoot}/src/*", 
       "webpack:///../../../../src/*": "${webRoot}/src/*", 
       "webpack:///../../../../../src/*": "${webRoot}/src/*" 
      }, 
      "runtimeArgs": [ 
       "--remote-debugging-port=9222" 
      ] 
     }, 
     { 
      "name": "SPFx Online", 
      "type": "chrome", 
      "request": "launch", 
      "url": "https://<your_tenant>.sharepoint.com/sites/<your_site>/SitePages/<your_webpart_page>.aspx", 
      "webRoot": "${workspaceRoot}", 
      "sourceMaps": true, 
      "sourceMapPathOverrides": { 
       "webpack:///../../../src/*": "${webRoot}/src/*", 
       "webpack:///../../../../src/*": "${webRoot}/src/*", 
       "webpack:///../../../../../src/*": "${webRoot}/src/*" 
      }, 
      "runtimeArgs": [ 
       "--remote-debugging-port=9222" 
      ] 
     }, 
     { 
      "name": "SPFx Online Workbench", 
      "type": "chrome", 
      "request": "launch", 
      "url": "https://<your_tenant>.sharepoint.com/_layouts/workbench.aspx", 
      "webRoot": "${workspaceRoot}", 
      "sourceMaps": true, 
      "sourceMapPathOverrides": { 
       "webpack:///../../../src/*": "${webRoot}/src/*", 
       "webpack:///../../../../src/*": "${webRoot}/src/*", 
       "webpack:///../../../../../src/*": "${webRoot}/src/*" 
      }, 
      "runtimeArgs": [ 
       "--remote-debugging-port=9222" 
      ] 
     } 
    ] 
} 

请让我知道是否有问题。

相关问题