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
*Restrict webpack peer dependency version to `< 4`. Compatibility with webpack 4 will be
31
-
added with the next major release (5.0.0).
32
-
*Support for [serverless-step-functions-offline][link-step-functions-offline]
31
+
*Webpack 2 support has been dropped in favor of Webpack 4
32
+
* Cleaned up configuration. You should now use a `custom.webpack` object to configure everything relevant for the plugin. The old configuration still works but will be removed in the next major release. For details see below.
33
+
*This 5.0.0 prerelease is based on the current 4.4.0
33
34
34
35
For the complete release notes see the end of this document.
35
36
@@ -48,12 +49,27 @@ plugins:
48
49
49
50
## Configure
50
51
51
-
By default the plugin will look for a `webpack.config.js` in the service directory.
52
-
Alternatively, you can specify a different file or configuration in `serverless.yml`:
52
+
The configuration of the plugin is done by defining a `custom: webpack` object in your `serverless.yml` with your specific configuration. All settings are optional and will be set to reasonable defaults if missing.
53
+
54
+
See the sections below for detailed descriptions of the settings. The defaults are:
55
+
56
+
```yaml
57
+
custom:
58
+
webpack:
59
+
webpackConfig: 'webpack.config.js' # Name of webpack configuration file
60
+
includeModules: false # Node modules configuration for packaging
61
+
packager: 'npm' # Reserved for future use. Any other values will not work right now.
62
+
packExternalModulesMaxBuffer: 200 * 1024 # Size of stdio buffers for spawned child processes
63
+
```
64
+
65
+
### Webpack configuration file
66
+
67
+
By default the plugin will look for a `webpack.config.js` in the service directory. Alternatively, you can specify a different file or configuration in `serverless.yml`.
53
68
54
69
```yaml
55
70
custom:
56
-
webpack: ./folder/my-webpack.config.js
71
+
webpack:
72
+
webpackConfig: ./folder/my-webpack.config.js
57
73
```
58
74
59
75
A base Webpack configuration might look like this:
@@ -126,6 +142,24 @@ as that will modify the running framework and leads to unpredictable behavior!
126
142
If you have cool use cases with the full customization, we might add your solution
127
143
to the plugin examples as showcase.
128
144
145
+
#### Invocation state
146
+
147
+
`lib.webpack`contains state variables that can be used to configure the build
148
+
dynamically on a specific plugin state.
149
+
150
+
##### isLocal
151
+
152
+
`lib.webpack.isLocal`is a boolean property that is set to true, if any known
153
+
mechanism is used in the current Serverless invocation that runs code locally.
154
+
155
+
This allows to set properties in the webpack configuration differently depending
156
+
if the lambda code is run on the local machine or deployed.
157
+
158
+
A sample is to set the compile mode with Webpack 4:
0 commit comments