JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4569
  • Score
    100M100P100Q132273F
  • License MIT

Webpack plugin to replace the AWS SAM CLI build command

Package Exports

  • aws-sam-webpack-plugin

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (aws-sam-webpack-plugin) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

npm node deps

AWS SAM Webpack Plugin

A Webpack plugin that replaces the sam build step for AWS SAM CLI projects.

Background

This plugin will build your AWS SAM CLI projects using Webpack in way that replaces the sam build step. I created this project because I wanted to write my Lambda using TypeScript then use Webpack to build them.

To use this plugin:

  1. Initialize your project using sam init
  2. Create a package.json in the project root folder using npm init
  3. Install Webpack and other devDependencies in the project root.

Note: To use this plugin every function needs to use the nodejs8.10 or nodejs10.x runtime. If your project uses other runtimes then you should look at Building Apps with SAM, TypeScript and VS Code Debugging.

Install

npm install sam-webpack-plugin --save-dev

Usage

This plugin looks for AWS::Serverless::Function resources in your template.yaml or template.yml then builds each of these as it's own entry point/output.

webpack.config.js

const AwsSamPlugin = require("aws-sam-webpack-plugin");

const awsSamPlugin = new AwsSamPlugin();

{
  // Loads the entry object from your template.yaml or tempalte.yml
  entry: awsSamPlugin.entry(),

  // Includes the aws-sdk only for development. The node10.x docker image
  // used by SAM CLI Local doens't include it but it's included in the actual
  // Lambda runtime.
  externals: process.env.NODE_ENV === "development" ? ["aws-sdk"] : [],

  // Add the AWS SAM Webpack plugin
  plugins: [
    awsSamPlugin
  ]
}

You can

Options

Name Type Default Description
vscodeDebug {Boolean} true Also generate a .vscode/launch.json file for debugging Lambda with SAM CLI local S

vscodeDebug

Enable/disable automatically generating a .vscode/launch.json file. This file contains the VS Code debug configuration for all of the Lambda's from your template.yaml.

webpack.config.js

const awsSamPlugin = new AwsSamPlugin({ vscodeDebug: false });

Maintainers


Rich Buggy