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
A Serverless v1.0 plugin to build your lambda functions with [Webpack](https://webpack.github.io).
8
+
A Serverless v1.x plugin to build your lambda functions with [Webpack][link-webpack].
7
9
8
-
This plugin is for you if you want to use the latest Javascript version with [Babel](https://babeljs.io/);
9
-
use custom [resource loaders](https://webpack.github.io/docs/loaders.html);
10
+
This plugin is for you if you want to use the latest Javascript version with [Babel][link-babel];
11
+
use custom [resource loaders][link-webpack-loaders];
10
12
try your lambda functions locally and much more!
11
13
12
14
> **BREAKING CHANGE IN v2**: `webpack` must now be installed alongside `serverless-webpack` as a peer dependency. This allows more control over which version of Webpack to run.
13
15
14
16
## Install
15
17
16
-
```
17
-
npm install serverless-webpack
18
+
```bash
19
+
$ npm install serverless-webpack --save-dev
18
20
```
19
21
20
22
Add the plugin to your `serverless.yml` file:
@@ -27,7 +29,7 @@ plugins:
27
29
## Configure
28
30
29
31
By default the plugin will look for a `webpack.config.js` in the service directory.
30
-
In alternative you can specify a different file or configuration in the `serverless.yml` with:
32
+
Alternatively, you can specify a different file or configuration in `serverless.yml`:
31
33
32
34
```yaml
33
35
custom:
@@ -36,7 +38,7 @@ custom:
36
38
37
39
An base Webpack configuration might look like this:
38
40
39
-
```javascript
41
+
```js
40
42
// webpack.config.js
41
43
42
44
module.exports = {
@@ -50,18 +52,18 @@ module.exports = {
50
52
51
53
Note that, if the `output` configuration is not set, it will automatically be
52
54
generated to write bundles in the `.webpack` directory. If you set your own `output`
53
-
configuration make sure to add a [`libraryTarget`](https://webpack.github.io/docs/configuration.html#output-librarytarget)
55
+
configuration make sure to add a [`libraryTarget`][link-webpack-libtarget]
54
56
for best compatibility with external dependencies:
55
57
56
-
```javascript
58
+
```js
57
59
// webpack.config.js
58
60
59
61
module.exports = {
60
62
// ...
61
63
output: {
62
64
libraryTarget: 'commonjs',
63
65
path: '.webpack',
64
-
filename: 'handler.js', // this should match the first part of function handler in serverless.yml
66
+
filename: 'handler.js', // this should match the first part of function handler in `serverless.yml`
65
67
},
66
68
// ...
67
69
};
@@ -72,7 +74,7 @@ want to include all modules in some cases such as selectively import, excluding
72
74
builtin package (ie: `aws-sdk`) and handling webpack-incompatible modules.
0 commit comments