serverless-rollup-plugin
A plugin for the serverless framework to build lambda code using rollup
Last updated 2 months ago by benforce .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install serverless-rollup-plugin 
SYNC missed versions from official npm registry.

Welcome to serverless-rollup-plugin ????

Build Status Maintainability npm version FOSSA Status

A plugin for the serverless framework to bundle lambda code using rollup

Install

yarn install serverless-rollup-plugin

Usage

Add the plugin to your serverless config:

plugins:
  - serverless-rollup-plugin
  - ...any other plugins

Under the custom property, add a section for rollup. The only required property to run rollup is the config property:

custom:
  rollup:
    config: ./rollup.config.js

For each function that you would like to use rollup option, just define the handler option as normal. You can optionally define the dependencies property as a list of packages to be installed in the node_modules folder in your lambda.

testFunction:
  handler: src/functions/testFunction/index.handler
  dependencies:
    - aws-xray-sdk-core
  copyFiles:
    - some/glob/**/*.pattern

Using Yarn

By default if you specify function dependencies npm will be used. You can override this by setting the installCommand property, like this:

custom:
  rollup:
    installCommand: yarn add

Add Global Dependency

If you want to add a dependency for every lambda function (for example adding source map support), you can add them to the rollup dependencies property:

custom:
  rollup:
    dependencies:
      - some-package-name

Output Options

If you don't specify output settings in your rollup config, the following defaults will be used:

{
  "format": "cjs",
  "sourcemap": true
}

Adding Sourcemap Support

You can easily get your lambda stack traces to show correct file/line information using the source-map-support package. To use this with the serverless-rollup-plugin, first install the package and add it to the universal dependencies:

custom:
  rollup:
    dependencies:
      - source-map-support

Then in your rollup config, set the output banner to install it:

export default {
  output: {
    format: "cjs",
    sourcemap: true,
    banner: "require('source-map-support').install();"
  }
};

If you do specify output settings, they will be used and only the file property will be overwritten.

Copying Resource Files

To copy a static file into your function deployment, use the copyFiles parameter. This parameter is an array of glob pattern strings, or objects with the following properties:

Name Required Description
glob Yes A glob pattern
srcBase No Part of the path that will be removed from the destination path
destination No Destination path within the lambda's directory structure

Author

???? Ben Force

???? Contributing

Contributions, issues and feature requests are welcome!

Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!


This README was generated with ❤️ by readme-md-generator

Current Tags

  • 1.7.2                                ...           latest (2 months ago)

21 Versions

  • 1.7.2                                ...           2 months ago
  • 1.7.1                                ...           2 months ago
  • 1.7.0                                ...           2 months ago
  • 1.6.2                                ...           2 months ago
  • 1.6.1                                ...           2 months ago
  • 1.6.0                                ...           4 months ago
  • 1.5.5                                ...           5 months ago
  • 1.5.4                                ...           5 months ago
  • 1.5.3                                ...           5 months ago
  • 1.5.2                                ...           5 months ago
  • 1.5.1                                ...           5 months ago
  • 1.5.0                                ...           5 months ago
  • 1.4.0                                ...           5 months ago
  • 1.3.2                                ...           6 months ago
  • 1.3.1                                ...           8 months ago
  • 1.3.0                                ...           8 months ago
  • 1.2.0                                ...           8 months ago
  • 1.1.1                                ...           8 months ago
  • 1.1.0                                ...           8 months ago
  • 1.0.2                                ...           9 months ago
  • 1.0.1                                ...           9 months ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (8)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |