Skip to content
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

Vscode debug #365

Merged
merged 5 commits into from
Apr 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,11 @@ Options are:
:exclamation: The serve command has been removed. See above how to achieve the
same functionality with the [`serverless-offline`][link-serverless-offline] plugin.

### vscode debugging

To debug your functions using `serverless invoke local` or `serverless-offline`
check this [`.vscode/launch.json example`][link-examples-babel-webpack-4-vscode-launch].

## Example with Babel

In the [`examples`][link-examples] folder there is a Serverless project using this
Expand Down Expand Up @@ -757,6 +762,7 @@ me to take it over and continue working on the project. That helped to revive it
[link-webpack-tree]: https://webpack.js.org/guides/tree-shaking/
[link-webpack-externals]: https://webpack.js.org/configuration/externals/
[link-examples]: ./examples
[link-examples-babel-webpack-4-vscode-launch]: ./examples/babel-webpack-4/.vscode/launch.json
[link-serverless-offline]: https://www.npmjs.com/package/serverless-offline
[ico-serverless-offline]: https://img.shields.io/npm/v/serverless-offline.svg
[link-serverless-dynamodb-local]: https://www.npmjs.com/package/serverless-dynamodb-local
Expand Down
77 changes: 77 additions & 0 deletions examples/babel-webpack-4/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Serverless Offline",
"program": "${workspaceRoot}/node_modules/serverless/bin/serverless",
"args": [ "offline", "--noTimeout", "--dontPrintOutput", "--stage=dev" ],
"sourceMaps": true,
"runtimeArgs": [
"--lazy"
],
"outFiles": [
"${workspaceFolder}/.webpack/**/*.js"
],
"protocol": "inspector",
"runtimeExecutable": "node",
"env": {
// Here we set some environment vars that should be set locally.
// They can and will overwrite the ones coming from your serverless.yml
},
"windows": {
"program": "${workspaceRoot}\\node_modules\\serverless\\bin\\serverless",
}
},
{
"type": "node",
"request": "launch",
"name": "Launch Invoke Local - first function",
"program": "${workspaceRoot}/node_modules/serverless/bin/serverless",
"args": [ "invoke", "local", "-f", "first", "--data", "{}" ],
"sourceMaps": true,
"runtimeArgs": [
"--lazy"
],
"outFiles": [
"${workspaceFolder}/.webpack/**/*.js"
],
"protocol": "inspector",
"runtimeExecutable": "node",
"env": {
// Here we set some environment vars that should be set locally.
// They can and will overwrite the ones coming from your serverless.yml
},
"windows": {
"program": "${workspaceRoot}\\node_modules\\serverless\\bin\\serverless",
}
},
{
"type": "node",
"request": "launch",
"name": "Launch Invoke Local - second function",
"program": "${workspaceRoot}/node_modules/serverless/bin/serverless",
"args": [ "invoke", "local", "-f", "second", "--data", "{}" ],
"sourceMaps": true,
"runtimeArgs": [
"--lazy"
],
"outFiles": [
"${workspaceFolder}/.webpack/**/*.js"
],
"protocol": "inspector",
"runtimeExecutable": "node",
"env": {
// Here we set some environment vars that should be set locally.
// They can and will overwrite the ones coming from your serverless.yml
},
"windows": {
"program": "${workspaceRoot}\\node_modules\\serverless\\bin\\serverless",
}
},
]
}
10 changes: 8 additions & 2 deletions examples/babel-webpack-4/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
This is the default babel webpack-4 example to look at, because only dynamic entry point resolution lets you use Serverless completely. Individual packaging with a per-function dependency optimization is only available with that approach.
This is the default babel webpack-4 example to look at, because only dynamic
entry point resolution lets you use Serverless completely.
Individual packaging with a per-function dependency optimization is only
available with that approach.

You can also try to invoke a function locally:
```
serverless invoke local --function=first --path=./event.json
```
```

Also it has a [.vscode/launch.json](.vscode/launch.json) file for debugging the
functions using `vscode`.
Loading