Skip to content

Commit 5cf2479

Browse files
authoredApr 6, 2018
Merge pull request #365 from franciscocpg/vscode-debug
Vscode debug
2 parents 9107e2e + 6fb04ea commit 5cf2479

File tree

6 files changed

+1312
-5484
lines changed

6 files changed

+1312
-5484
lines changed
 

‎README.md

+6
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,11 @@ Options are:
548548
:exclamation: The serve command has been removed. See above how to achieve the
549549
same functionality with the [`serverless-offline`][link-serverless-offline] plugin.
550550

551+
### vscode debugging
552+
553+
To debug your functions using `serverless invoke local` or `serverless-offline`
554+
check this [`.vscode/launch.json example`][link-examples-babel-webpack-4-vscode-launch].
555+
551556
## Example with Babel
552557

553558
In the [`examples`][link-examples] folder there is a Serverless project using this
@@ -757,6 +762,7 @@ me to take it over and continue working on the project. That helped to revive it
757762
[link-webpack-tree]: https://webpack.js.org/guides/tree-shaking/
758763
[link-webpack-externals]: https://webpack.js.org/configuration/externals/
759764
[link-examples]: ./examples
765+
[link-examples-babel-webpack-4-vscode-launch]: ./examples/babel-webpack-4/.vscode/launch.json
760766
[link-serverless-offline]: https://www.npmjs.com/package/serverless-offline
761767
[ico-serverless-offline]: https://img.shields.io/npm/v/serverless-offline.svg
762768
[link-serverless-dynamodb-local]: https://www.npmjs.com/package/serverless-dynamodb-local
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "launch",
10+
"name": "Launch Serverless Offline",
11+
"program": "${workspaceRoot}/node_modules/serverless/bin/serverless",
12+
"args": [ "offline", "--noTimeout", "--dontPrintOutput", "--stage=dev" ],
13+
"sourceMaps": true,
14+
"runtimeArgs": [
15+
"--lazy"
16+
],
17+
"outFiles": [
18+
"${workspaceFolder}/.webpack/**/*.js"
19+
],
20+
"protocol": "inspector",
21+
"runtimeExecutable": "node",
22+
"env": {
23+
// Here we set some environment vars that should be set locally.
24+
// They can and will overwrite the ones coming from your serverless.yml
25+
},
26+
"windows": {
27+
"program": "${workspaceRoot}\\node_modules\\serverless\\bin\\serverless",
28+
}
29+
},
30+
{
31+
"type": "node",
32+
"request": "launch",
33+
"name": "Launch Invoke Local - first function",
34+
"program": "${workspaceRoot}/node_modules/serverless/bin/serverless",
35+
"args": [ "invoke", "local", "-f", "first", "--data", "{}" ],
36+
"sourceMaps": true,
37+
"runtimeArgs": [
38+
"--lazy"
39+
],
40+
"outFiles": [
41+
"${workspaceFolder}/.webpack/**/*.js"
42+
],
43+
"protocol": "inspector",
44+
"runtimeExecutable": "node",
45+
"env": {
46+
// Here we set some environment vars that should be set locally.
47+
// They can and will overwrite the ones coming from your serverless.yml
48+
},
49+
"windows": {
50+
"program": "${workspaceRoot}\\node_modules\\serverless\\bin\\serverless",
51+
}
52+
},
53+
{
54+
"type": "node",
55+
"request": "launch",
56+
"name": "Launch Invoke Local - second function",
57+
"program": "${workspaceRoot}/node_modules/serverless/bin/serverless",
58+
"args": [ "invoke", "local", "-f", "second", "--data", "{}" ],
59+
"sourceMaps": true,
60+
"runtimeArgs": [
61+
"--lazy"
62+
],
63+
"outFiles": [
64+
"${workspaceFolder}/.webpack/**/*.js"
65+
],
66+
"protocol": "inspector",
67+
"runtimeExecutable": "node",
68+
"env": {
69+
// Here we set some environment vars that should be set locally.
70+
// They can and will overwrite the ones coming from your serverless.yml
71+
},
72+
"windows": {
73+
"program": "${workspaceRoot}\\node_modules\\serverless\\bin\\serverless",
74+
}
75+
},
76+
]
77+
}

‎examples/babel-webpack-4/README.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
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.
1+
This is the default babel webpack-4 example to look at, because only dynamic
2+
entry point resolution lets you use Serverless completely.
3+
Individual packaging with a per-function dependency optimization is only
4+
available with that approach.
25

36
You can also try to invoke a function locally:
47
```
58
serverless invoke local --function=first --path=./event.json
6-
```
9+
```
10+
11+
Also it has a [.vscode/launch.json](.vscode/launch.json) file for debugging the
12+
functions using `vscode`.

0 commit comments

Comments
 (0)