# sam-lambda-plugin

> Webpack plugin for building minimal AWS SAM apis

Latest version **0.0.1** (published 2019-04-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install sam-lambda-plugin
pnpm add sam-lambda-plugin
yarn add sam-lambda-plugin
bun add sam-lambda-plugin
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2019-04-03 |
| First published | 2019-04-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 83.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Garrett Culos |
| Maintainers | garrettc |

## Links

- npm: https://www.npmjs.com/package/sam-lambda-plugin
- Repository: https://github.com/GarrettCulos/lambda-webpack-plugin
- Issues: https://github.com/GarrettCulos/lambda-webpack-plugin
- npm.io page: https://npm.io/package/sam-lambda-plugin

## Dependencies (6)

- [mv](https://npm.io/package/mv.md) ^2.1.1
- [cpx](https://npm.io/package/cpx.md) ^1.5.0
- [rimraf](https://npm.io/package/rimraf.md) ^2.6.3
- [archiver](https://npm.io/package/archiver.md) ^3.0.0
- [fs-extra](https://npm.io/package/fs-extra.md) ^7.0.1
- [make-dir](https://npm.io/package/make-dir.md) ^3.0.0

## Recent versions

- 0.0.1 (latest) — 2019-04-03

## README

## Getting Started

Requirements: webpack knowledge

Import `SamWebpackPlugin` into your webpack config file.

Add the plugin to the webpack plugin block,

```
    ...
    plugins:[
        ...
        new SamWebpackPlugin({
            baseTemplate: './template.json'
        })
        ...
    ]
```

The `template.json` file is the base SAM/CloudFront template used for all defined lambda functions.
Before each lambda function, we can define our sam config with the following;

```
/*
@WebpackLambda({
  "Properties": {
    "Handler": "lambdaFunction.lambdaHandler",
    "Events":{
      "GetData":{
        "Type": "Api",
        "Properties": {
          "Path": "/api/v1/data",
          "Method": "get"
        }
      }
    }
  }
})
*/
```

On build, FOR EACH entry having the `@WebpackLambda` decorator, the content within each `@WebpackLambda(*)` will be parsed into the baseTemplate config. Note:

- ANY CodeUri provided within each decorate will be replaced by the plugin
- The `@WebpackLambda()` must be declared within a comment block like above
- The Config defined within each file will be parse into `Resources.<fileName>`. See the examples folder for more details.
- No validation on the config provided occurs, the config must comply with AWS SAM AWS::SERVERLESS::FUNCTION

## Working with local external packages

- user layers option to import locally defined external packages into your lambda function deployment packages.

## TODO

x add plugin options verification
x expand on jsdoc descriptions

x add docs on how plugin works.

x create git project (prettier, ci/cd to npm, example projects)

- add tests
- deploy to npm
- add plugin JSON object verification
- explore decorator loader for @WebpackLambda

---
_Source: https://npm.io/package/sam-lambda-plugin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
