-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using VS Code chrome debug extension #144
Comments
@sumigoma 👍 Nice plugin, didn't know about it |
@sumigoma do you think you can make the file and make a pull-request? |
I have half an hour of time, giving it a go 😄 |
I would, but I haven't been able to come up with a launch.json config that works.. I'm wondering if it's because webpack-dev-server doesn't write its bundles to disk (so the extension can't access any source maps) or if it's something else. I've been playing with moving the build folder into src/public, etc., but no luck so far. |
yeah it doesn't write to disk since it's all in-memory so perhaps that is a problem |
@sumigoma @gdi2290 Currently taking a look at this repo which uses it apparently with webpack: https://github.com/skolmer/react-hot-boilerplate-vscode //Edit: Also this one: https://github.com/Microsoft/vscode-chrome-debug/issues/63 |
Yep, I've been following the developments, but this project is structured a little differently, and the webpack configuration differs as well.. Will keep messing with it. |
The main change in configuration to get vscode-chrome-debug working with webpack-dev-server is described here: skolmer/react-hot-boilerplate-vscode#1 If someone finds a better way to get vscode chrome debugger working with webpack-dev-server please let us know at https://github.com/Microsoft/vscode-chrome-debug/issues/63 |
I tried to set devtoolModuleFilenameTemplate in webpack config to "file:///" and it works. Here's the change for the webpack configuration:
launch.json:
The issue in this case is that the webpack is not writing to disk so I run another npm run watch to watch the changes and get the rebuild files. But it seems not efficient. Hope there's a solution that don't need to have to process run at the same time. |
I included this into the readme via e336583 |
A working sample here: https://github.com/tan9/angular2-webpack-starter/pull/1/filesI'm a newbie for modern front-end development. I found it is very tricky to make this project run with VSCode debugger. After two days' try-and-error, I finally made the working sample. If you are in trouble with VSCode debugging, maybe this can help you out. Thanks @Gabriel0402 for providing a snippet for a good start. However, the Note: DO NOT put any space in your workspace path. (3/24 updated: vscode-chrome-debug 0.2.3 fixed the space in path issue here.) |
@tan9 This is great work. I can also make my debugger work with this write to file plugin. And some little suggestions to the PR. For windows machine, the launch.json should be
And I don't know if there're some edge cases for the check of absolute path, but your devtoolModuleFilenameTemplate didn't work for me which is windows os. And I'm still using
to make it work. Cheers |
@Gabriel0402 to make this work on osx and windows you can use the following configuration:
|
@Gabriel0402, for chrome For the @skolmer In my OS X, devtoolModuleFilenameTemplate: function (info) {
var resourcePath = info.absoluteResourcePath;
if (resourcePath.indexOf(__dirname) !== 0) {
// Normalize resouce path if it is not an absolute path
// (e.g. 'node_modules/rxjs/Observable.js')
resourcePath = helpers.root(resourcePath);
}
if (resourcePath.charAt(0) === '/') {
// Mac OS X absolute path has a leading slash already
// https://github.com/Microsoft/vscode-chrome-debug/issues/63#issuecomment-163524778
return 'file://' + resourcePath;
} else {
return 'file:///' + resourcePath;
}
} Can you break on |
@tan9 You can have a separate chrome session per project if you set chrome's userDataDir in your launch.json Not sure why absoluteResourcePath contains a relative path in your case. What devtool is set in your webpack config? I'm using |
@skolmer Thanks for the I am using |
I got it to work with the latest (1.1) version of visual studio code by only changing a couple of things after a clean install of both vscode and angular2-webpack-starter: use install and use the write-file-webpack-plugin : and add the plugin to ./config/webpack.dev.js by adding : this ensures the source-maps are written to disk. finally, use this launch-config :
notice the absence of '/dist/' in the webroot. with this config, source-maps are in ./dist/, but they point to ./src/. vscode prepends the absolute root to the workspace, and correctly resolves the file. also, in the latest version of the debugger, vscode already fixes the webpack:/// urls in the source-maps, so you don't have to. hope this helps someone. edit : I forgot one thing : the write-file-webpack-plugin is still needed. will update this later. |
I just noticed that after following my own procedure, I hit a bug in vscode, I think. on the first run of the project, when I immediately start a debugging session before opening any source files, vscode hangs and must be killed. opening a single file before beginning a debug alleviates this. |
@tech-no-logical, your comment got it working for me. Thanks much! One typo: I am also seeing the vscode hang that you mention in your second comment. |
@tech-no-logical, that worked for me too. Thanks lot buddy. I had to modify one more thing in my webpack.dev.js file, removed sourceMapFilename: [name].map.js from output: section. Let webpack do by itself to create the source map files, otherwise your Breakpoint will not hit in TypeScript file, but in JS streamed content instead. Please also note that these changes only do in dev config not in prod environment. And here is my partial webpack.dev.js: `
|
@tech-no-logical, It's working for me. But VS code getting hang as config your procedure. |
I followed the directions in @Anujarya300 comment and got it working. But then found that all that was needed of that code (in the latest version of the starter) was to add |
The bellow config works for me,
Also |
@trkrameshkumar or just |
I'm not sure if this falls within the scope of this project, but it would be nice to establish the correct launch.json configuration to make this project debuggable within VS Code using this extension (https://github.com/Microsoft/vscode-chrome-debug), given the webpack configuration used here.
Has anyone had any luck with this?
The text was updated successfully, but these errors were encountered: