Skip to content

flybondi/serverless-rollup-plugin

Repository files navigation

@flybondi/serverless-rollup-plugin

semantic-release js-semistandard-style code style: prettier

A Serverless plugin to build your lambda functions with Rollup. Optimize your packaged functions individually and much more!

Overview

Rollup is a module bundler for JavaScript which compiles small pieces of code into something larger and more complex, such as a library or application. It uses the new standardized format for code modules included in the ES6 revision of JavaScript, instead of previous idiosyncratic solutions such as CommonJS and AMD. ES modules let you freely and seamlessly combine the most useful individual functions from your favorite libraries. This will eventually be possible natively everywhere, but Rollup lets you do it today.

Install

  yarn add @flybondi/serverless-rollup-plugin --dev

Add the plugin to your serverless.yml file:

custom:
  config: rollup.config.js
plugins:
  - serverless-rollup-plugin

Configure

The configuration of the plugin is done by defining a custom: rollup object in your serverless.yml with the path to your specific configuration file. For information on how to create the config file could be found here.

Usage

Automatic bundling

The normal Serverless deploy procedure will automatically bundle with rollup:

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