# serverless-webapp-deployments-plugin

> A plugin for serverless to easily build, deploy and publish webapps to s3

Latest version **1.0.6** (published 2019-05-10) · ISC license · 0 weekly downloads

## Install

```sh
npm install serverless-webapp-deployments-plugin
pnpm add serverless-webapp-deployments-plugin
yarn add serverless-webapp-deployments-plugin
bun add serverless-webapp-deployments-plugin
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2019-05-10 |
| First published | 2019-02-28 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jayesh Malhotra |
| Maintainers | jayeshayz |

## Links

- npm: https://www.npmjs.com/package/serverless-webapp-deployments-plugin
- Repository: https://github.com/jayesh100/serverless-webapp-deployments-plugin
- Homepage: https://github.com/jayesh100/serverless-webapp-deployments-plugin#readme
- Issues: https://github.com/jayesh100/serverless-webapp-deployments-plugin/issues
- npm.io page: https://npm.io/package/serverless-webapp-deployments-plugin

## Recent versions

- 1.0.6 (latest) — 2019-05-10
- 1.0.5 — 2019-05-10
- 1.0.4 — 2019-03-09
- 1.0.3 — 2019-02-28
- 1.0.2 — 2019-02-28
- 1.0.1 — 2019-02-28
- 1.0.0 — 2019-02-28

## README

# serverless-webapp-deployments-plugin

### THIS IS AN EXTENDED VERSION OF 'serverless-single-page-app-plugin' WITH MINOR CHANGES FOR A PARTICULAR USE CASE

A plugin for [Serverless Framework](https://serverless.com), to simplify deploying a Webapp on S3. 

Based on the [official example](https://github.com/serverless/examples/tree/master/aws-node-single-page-app-via-cloudfront/serverless-single-page-app-plugin), with some important tweaks:

- Auto-generated bucket name, to allow multiple independent deployments without name-clashes
- Packaged as its own repo, so that it can be re-used and independently versioned
- Build your web app : `serverless buildWebapp`
- Publish your web app (to s3) : `serverless publishWebapp`
- Deploy (build + publish) : `serverless deployWebapp`
- One command deployments (with `sls deploy`)

## Installation

Install the package via NPM:

```bash
npm install serverless-webapp-deployments-plugin
```

Then register it in your `serverless.yml` file, as a plugin:

```
plugins:
  - serverless-webapp-deployments-plugin
```

And set `s3Bucket`, `appBuildPath`, `buildCommand`, `oneCmdDeploy` custom variables:

```
custom:
  s3Bucket: my-special-bucket # Name of s3 bucket
  appBuildPath: webapp/dist # Location of the build path (contains index.html)
  buildCommand: build-app # The npm script run to build the webapp
  oneCmdDeploy: true # Deploys webapp immediately after 'sls deploy' is run - false by default
```

Finally, add appropriately-named resources (Bucket and BucketPolicy) and Outputs:

```
resources:
  Resources:
    # Specifying the S3 Bucket
    WebAppS3Bucket:
      Type: AWS::S3::Bucket
      Properties:
        BucketName: ${self:custom.s3Bucket}
        AccessControl: PublicRead
        WebsiteConfiguration:
          IndexDocument: index.html
          ErrorDocument: index.html
    # Specifying the policies to make sure all files inside the Bucket are avaialble
    WebAppS3BucketPolicy:
      Type: AWS::S3::BucketPolicy
      Properties:
        Bucket:
          Ref: WebAppS3Bucket
        PolicyDocument:
          Statement:
            - Sid: PublicReadGetObject
              Effect: Allow
              Principal: '*'
              Action:
              - s3:GetObject
              Resource:
                Fn::Join:
                  - ''
                  -
                    - 'arn:aws:s3:::'
                    - !Ref WebAppS3Bucket
                    - '/*'
  # In order to print out the hosted domain we can run `serverless info`
  Outputs:
    WebAppUrl:
      Value: !GetAtt WebAppS3Bucket.WebsiteURL
```

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