Skip to content

Commit d36f9a8

Browse files
author
Frank Schmid
committedMar 7, 2018
Documented new configuration
1 parent 3ed8365 commit d36f9a8

File tree

1 file changed

+34
-14
lines changed

1 file changed

+34
-14
lines changed
 

‎README.md

+34-14
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ WebPack's [Tree-Shaking][link-webpack-tree] optimization.
2929
## Recent improvements and important changes
3030

3131
* 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.
3233
* This 5.0.0 prerelease is based on the current 4.4.0
3334

3435
For the complete release notes see the end of this document.
@@ -48,12 +49,27 @@ plugins:
4849
4950
## Configure
5051
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+
webpackIncludeModules: 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`.
5368

5469
```yaml
5570
custom:
56-
webpack: ./folder/my-webpack.config.js
71+
webpack:
72+
webpackConfig: ./folder/my-webpack.config.js
5773
```
5874

5975
A base Webpack configuration might look like this:
@@ -209,7 +225,8 @@ module.exports = {
209225
```yaml
210226
# serverless.yml
211227
custom:
212-
webpackIncludeModules: true # enable auto-packing of external modules
228+
webpack:
229+
webpackIncludeModules: true # enable auto-packing of external modules
213230
```
214231

215232

@@ -223,8 +240,9 @@ use a different package file, set `packagePath` to your custom `package.json`:
223240
```yaml
224241
# serverless.yml
225242
custom:
226-
webpackIncludeModules:
227-
packagePath: '../package.json' # relative path to custom package.json file.
243+
webpack:
244+
webpackIncludeModules:
245+
packagePath: '../package.json' # relative path to custom package.json file.
228246
```
229247
> Note that only relative path is supported at the moment.
230248

@@ -246,10 +264,11 @@ your service's production dependencies in `package.json`.
246264
```yaml
247265
# serverless.yml
248266
custom:
249-
webpackIncludeModules:
250-
forceInclude:
251-
- module1
252-
- module2
267+
webpack:
268+
webpackIncludeModules:
269+
forceInclude:
270+
- module1
271+
- module2
253272
```
254273

255274
#### Forced exclusion
@@ -262,10 +281,11 @@ Just add them to the `forceExclude` array property and they will not be packaged
262281
```yaml
263282
# serverless.yml
264283
custom:
265-
webpackIncludeModules:
266-
forceExclude:
267-
- module1
268-
- module2
284+
webpack:
285+
webpackIncludeModules:
286+
forceExclude:
287+
- module1
288+
- module2
269289
```
270290

271291
If you specify a module in both arrays, `forceInclude` and `forceExclude`, the

0 commit comments

Comments
 (0)