You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+25-10Lines changed: 25 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -4,11 +4,11 @@ This is a small CLI tool that helps with building or serving lambdas built with
4
4
5
5
The goal is to make it easy to work with Lambda's with modern ES6 without being dependent on having the most state of the art node runtime available in the final deployment environment and with a build that can compile all modules into a single lambda file.
6
6
7
-
## Installation
7
+
Since v1.0.0 the dependencies were upgraded to Webpack 4 and Babel 7.
8
8
9
-
We recommend installing locally rather than globally: `yarn add -D netlify-lambda`
9
+
## Installation
10
10
11
-
At the present moment you may have to also install peer dependencies [as documented here](https://github.com/netlify/netlify-lambda/issues/35) - we will correct this for the next release when we update our [webpack and babel versions](https://github.com/netlify/netlify-lambda/pull/15).
11
+
**We recommend installing locally** rather than globally: `yarn add -D netlify-lambda`. This will ensure your build scripts don't assume a global install which is better for your CI/CD (for example with Netlify's buildbot).
12
12
13
13
## Usage
14
14
@@ -19,7 +19,7 @@ netlify-lambda serve <folder>
19
19
netlify-lambda build <folder>
20
20
```
21
21
22
-
Both depends on a `netlify.toml` file being present in your project and configuring functions for deployment.
22
+
**IMPORTANT**: Both commands depend on a `netlify.toml` file being present in your project and configuring functions for deployment.
23
23
24
24
The `serve` function will start a dev server and a file watcher for the specified folder and route requests to the relevant function at:
25
25
@@ -29,38 +29,53 @@ http://localhost:9000/hello -> folder/hello.js (must export a handler(event, con
29
29
30
30
The `build` function will run a single build of the functions in the folder.
31
31
32
+
There are additional options, introduced later:
33
+
```bash
34
+
-h --help
35
+
-c --config
36
+
-p --port
37
+
```
38
+
32
39
### Proxying for local development
33
40
34
-
When your function is deployed on Netlify, it will be available at `/.netlify/functions/function-name` for any given deploy context. It is advantageous to proxy the `netlify-lambda serve` development server to the same path on your primary development server.
41
+
When your function is deployed on Netlify, it will be available at `/.netlify/functions/function-name` for any given deploy context. It is advantageous to proxy the `netlify-lambda serve` development server to the same path on your primary development server.
35
42
36
-
Say you are running `webpack-serve` on port 8080 and `netlify-lambda serve` on port 9000. Mounting `localhost:9000` to `/.netlify/functions/` on your `webpack-serve` server (`localhost:8080/.netlify/functions/`) will closely replicate what the final production environment will look like during development, and will allow you to assume the same function url path in development and in production.
43
+
Say you are running `webpack-serve` on port 8080 and `netlify-lambda serve` on port 9000. Mounting `localhost:9000` to `/.netlify/functions/` on your `webpack-serve` server (`localhost:8080/.netlify/functions/`) will closely replicate what the final production environment will look like during development, and will allow you to assume the same function url path in development and in production.
37
44
38
45
See [netlify/create-react-app-lambda](https://github.com/netlify/create-react-app-lambda/blob/3b5fac5fcbcba0e775b755311d29242f0fc1d68e/package.json#L19) for an example of how to do this.
The serving port can be changed with the `-p`/`--port` option.
64
+
56
65
## Webpack Configuration
57
66
58
67
By default the webpack configuration uses `babel-loader` to load all js files. Any `.babelrc` in the directory `netlify-lambda` is run from will be respected. If no `.babelrc` is found, a [few basic settings are used](https://github.com/netlify/netlify-lambda/blob/master/lib/build.js#L11-L15a).
59
68
60
-
If you need to use additional webpack modules or loaders, you can specify an additional webpack config with the `-c` option when running either `serve` or `build`.
69
+
If you need to use additional webpack modules or loaders, you can specify an additional webpack config with the `-c`/`--config` option when running either `serve` or `build`.
61
70
62
71
The additional webpack config will be merged into the default config via [webpack-merge's](https://www.npmjs.com/package/webpack-merge)`merge.smart` method.
63
72
73
+
### babel configuration
74
+
75
+
The default webpack configuration uses `babel-loader` with a [few basic settings](https://github.com/netlify/netlify-lambda/blob/master/lib/build.js#L19-L33).
76
+
77
+
However, if any `.babelrc` is found in the directory `netlify-lambda` is run from, it will be used instead of the default one.
0 commit comments