Skip to content

Add in debugging recipe, delete unused categories from cookbook TOC #1464

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

Merged
merged 5 commits into from
Mar 21, 2018

Conversation

sdras
Copy link
Member

@sdras sdras commented Feb 28, 2018

Kenneth Auchenberg wrote a great recipe for debugging Vue within VSCode, and we agreed it should live in our cookbook as well. In addition to his great contribution, I've also added:

  • Alternative pattern: vue devtools
  • Alternative pattern: vuetron
  • Alternative pattern: simple debugging statement
  • As discussed, removal of sections for cookbook until we have a few more and can see more pertinent groupings

@sdras sdras requested a review from chrisvfritz February 28, 2018 16:42
@sdras
Copy link
Member Author

sdras commented Feb 28, 2018

@auchenberg I would love to get your take on this as well.

@sdras sdras added the cookbook label Feb 28, 2018
Copy link

@auchenberg auchenberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Be aware that we have identified a few issues that also are present in Chrome DevTools: vuejs/vue-loader#1163

@@ -0,0 +1,132 @@
---
title: Debugging in VSCode and Chrome

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually say "VS Code" or "Visual Studio Code"

order: 6
---

Every application reaches a point where it's necessary to understand failures, small to large. In this recipe, we explore a few workflows for VSCode users, who are using Chrome to test.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VS Code


## Prerequisites

You must have Chrome and VSCode installed. Make sure to the latest version of [Debugger for Chrome](https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome) extension installed in VS Code.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VS Code

@sdras
Copy link
Member Author

sdras commented Mar 1, 2018

Oh, that's too bad about the invalid sourcemaps. I'll synch with you offline about timeline. I can get the other changes in in the meantime.

this.$reverseText('message')
console.log(this.message) // => "olleH"
console.log(this.message) // => "olleH"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like these will were probably automatically formatted by Prettier. We've previously followed the StandardJS conventions in the Vue docs, but I've actually been thinking about moving towards Standard + Prettier overall, with linting built into the project so this is probably OK.


## Prerequisites

You must have Chrome and VS Code installed. Make sure to the latest version of [Debugger for Chrome](https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome) extension installed in VS Code.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to the latest version

Missing word here I think.

yarn global add @vue/cli

vue create my-project
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we should just defer people to the instructions in the Vue CLI README. That way, we don't have to update recipes if the API of Vue CLI changes. Thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that makes a lot of sense to me.


# if you have an alias set up (recommended)
code .
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part doesn't necessarily have to be done in the terminal and I've found some people prefer to instead open VS Code, then open a folder from there. Maybe we should assume knowledge of how to use the basics of VS Code and just ask people to open the project folder? That way, we're not assuming an alias is set up and that this is how the user prefers to open projects.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we don't mention here how to set up the alias, either, so this might avoid confusion

code .
```

### Update your webpack configuration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When referring to project names, we use a Title Case convention (e.g. Webpack instead of webpack). We're also currently using Title Case for titles (e.g. Update Your Webpack Configuration instead of Update your webpack configuration).


### Update your webpack configuration

Before you can debug your Vue components from VS Code you need to update the generated webpack config to build sourcemaps that contains more information for our debugger.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last time I'll mention it, but webpack->Webpack again here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sourcemaps that contains more information

contains->contain?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should probably also be more specific than "more information for our debugger" for those who don't know what source maps are.

devtool: 'source-map',
```

### Configure launch.json File
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

launch.json should probably be in backticks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, with these titles, I wonder if it might be better to use titles that describe what we're trying to achieve, instead of the implementation details to get there.

For example, instead of Update your webpack configuration, we could say Showing Source Code in the Chrome Devtools. Then instead of Configure launch.json File, we could say, Launching Our App from VS Code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that makes more sense and is probably more easily googleable (not a word, but I'm keeping it)

}
```

## Start Debugging An Application
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe Adding a Breakpoint?


<p class="tip">There are a couple of gotchas to note for Vue Devtools:
- If the page uses a production/minified build of Vue.js, devtools inspection is disabled by default so the Vue pane won't show up.
- To make it work for pages opened via file:// protocol, you need to check "Allow access to file URLs" for this extension in Chrome's extension management panel</p>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whenever there's another doc that explains something in more detail, it's best to link to it so that we don't have to maintain multiple versions of the same instructions. In this case, I'd just link to the Vue Devtools README, since it contains all this information already.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I'm thinking about keeping a note about it not working for minified version, but maybe changing the wording to say "for instance, using a CDN" because I get this question a ton and it really wouldn't hurt to have it in one more place, IMO.

@sdras
Copy link
Member Author

sdras commented Mar 9, 2018

Ok, I think I addressed all of the concerns in the review. Let me know if we need further changes :)

Copy link
Contributor

@chrisvfritz chrisvfritz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@sdras sdras merged commit 5c6e98b into vuejs:master Mar 21, 2018
@sdras
Copy link
Member Author

sdras commented Mar 21, 2018

Sourcemap issue made some traction, getting this recipe in there :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants