You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
Nicola Peduzzi 66f674e323 Add stage prefix to simulated urls 8 years ago
example Fix example npm import 8 years ago
lib Add stage prefix to simulated urls 8 years ago
.gitignore Add example 8 years ago
.npmignore Add example 8 years ago
LICENSE Add license 8 years ago
README.md Add example 8 years ago
index.js Merge branch 'master' into add-serve-command 8 years ago
package.json Add initial serve command 8 years ago

README.md

Serverless Webpack

serverless

A Serverless v1.0 plugin to build your lambda functions with Webpack.

Install

npm install serverless-webpack

Add the plugin to your serverless.yml file:

plugins:
  - serverless-webpack

By default the plugin will look for a webpack.config.js in the service directory. In alternative you can specify a different file or configuration in the serverless.yml with:

custom:
  webpack: ./folder/my-webpack.config.js

Note that, if the output configuration is not set, it will automatically be generated to write bundles in the .webpack directory.

Usage

The normal Serverless deploy procedure will automatically bundle with Webpack:

  • Create the Serverless project with serverless create -t aws-node
  • Install Serverless Webpack as above
  • Deploy with serverless deploy

To run your bundled functions locally you can:

serverless webpack run --function <function-name>

Or to run a function every time the source files change use watch:

serverless webpack watch --function <function-name> --path event.json

For both commands the options are:

  • --function or -f (required) is the name of the function to run
  • --path or -p (optional) is a JSON file path used as the function input event

Lastly use serverless webpack --out dist to compile files in the dist directory.

Example with Babel

In the example folder there is a Serverless project using this plugin with Babel. To try it, from inside the example folder:

  • npm install to install dependencies
  • serverless webpack run -f hello to run the example function