Skip to content

elastic-coders/serverless-runtime-webpack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Webpack Runtime for Serverless

serverless

A plugin to use Webpack to run and build your Serverless function.

🚀 For Serverless v1.0 check out the new implementation of this plugin called serverless-webpack.

This plugin is heavily inspired by serverless-runtime-babel and serverless-webpack-plugin.

Features

  • Runs locally and deploys functions bundled with Webpack
  • Compile all your dependencies in a single JS file
  • Use any loader you want, Babel with ES2015 and stage-0 presets is already bundled with this plugin

Install

Note: Serverless v0.5.0 or higher is required.

  • Install via npm in the root of your Serverless Project: npm install serverless-runtime-webpack --save-dev
  • In the plugins array in your s-project.json add "serverless-runtime-webpack"
  • Install the loaders you will use in your Webpack configuration npm install babel-loader --save-dev
  • All done!

Usage

All you need is to set runtime property of s-function.json to webpack.

From scratch you can:

  • serverless project create as usual
  • serverless function create myfunc and select webpack when asked for a runtime
  • serverless function run myfun done!

Scaffold

You can use serverless function create as usual — it will prompt you for a runtime unless you add the -r webpack flag.

Examples

GitHub stargazers example returns amount of starts for a GitHub repo.

Copy the stars folder in a Serverless project configured with this plugin as described in the Install section above; then run serverless function run stars.

Options

Configuration options can be used by setting the custom.runtime of s-function.json. The following options are available:

  • webpack – The Webpack configuration also accepting an extra (optional) property configPath with he path of the Webpack configuration file relative to the project

Example

Example Webpack Runtime configuration with default values:

{
  /*s-function.json*/
  /*...*/
  "runtime": "webpack",
  "custom": {
    "webpack": {
      "configPath": "myfunc/webpack.config.js"
    }
  },
  /*...*/
}

About

Webpack runtime for the Serverless Framework

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •