Skip to content

Commit

Permalink
Merge pull request #365 from franciscocpg/vscode-debug
Browse files Browse the repository at this point in the history
Vscode debug
  • Loading branch information
HyperBrain authored Apr 6, 2018
2 parents 9107e2e + 6fb04ea commit 5cf2479
Show file tree
Hide file tree
Showing 6 changed files with 1,312 additions and 5,484 deletions.
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

0 comments on commit 5cf2479

Please sign in to comment.