Browse Source

rename serverless custom key, includePackages to webpackIncludeModules to avoid conflict with other plugin

master
Tony Yuen 8 years ago
parent
commit
6176dc4c62
  1. 12
      README.md
  2. 2
      examples/include-external-npm-packages/serverless.yml
  3. 2
      examples/include-external-npm-packages/webpack.config.js
  4. 2
      lib/packExternalModules.js

12
README.md

@ -31,24 +31,24 @@ generated to write bundles in the `.webpack` directory.
By default, the plugin will try to bundle all dependencies. However, you don't
want to include all packages in some cases such as selectively import, excluding
builtin package (aws-sdk) and handling webpack-incompatible packages. In this case,
you add all the packages, you want to exclude from bundled files, into `externals` field
want to include all modules in some cases such as selectively import, excluding
builtin package (aws-sdk) and handling webpack-incompatible modules. In this case,
you add all the modules, you want to exclude from bundled files, into `externals` field
of your `webpack.config.json` and add those, you want to include in final distribution,
into `serverless.yml`:
```json
// webpack.config.json
{
externals: ["package1", "package2"] // packages to be excluded from bundled file
externals: ["module1", "module2"] // modules to be excluded from bundled file
}
```
```yaml
# serverless.yml
custom:
includePackages:
- package1 # packages to be included in distribution
webpackIncludeModules:
- module1 # modules to be included in distribution
```
You can find an example setup in the [`examples`](./examples) folder.

2
examples/include-external-npm-packages/serverless.yml

@ -9,7 +9,7 @@ provider:
runtime: nodejs4.3
custom:
includePackages: # packages to be included in distribution
webpackIncludeModules: # modules to be included in distribution
- fbgraph
functions:

2
examples/include-external-npm-packages/webpack.config.js

@ -3,5 +3,5 @@ var path = require('path');
module.exports = {
entry: './handler.js',
target: 'node',
externals: ["fbgraph", "aws-sdk"] // packages to be excluded from bundled file
externals: ["fbgraph", "aws-sdk"] // modules to be excluded from bundled file
};

2
lib/packExternalModules.js

@ -10,7 +10,7 @@ module.exports = {
const includes = (
this.serverless.service.custom &&
this.serverless.service.custom.includePackages
this.serverless.service.custom.webpackIncludeModules
);
return BbPromise.resolve().then(() => {

Loading…
Cancel
Save