Giter Site home page Giter Site logo

mykolasmolis / serverless-frontend-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rogersgt/serverless-frontend-plugin

0.0 0.0 0.0 1.22 MB

Serverless plugin to automate packaging and deploying a frontend UI in AWS Cloudfront and S3

JavaScript 52.00% HTML 3.70% CSS 0.47% Vue 43.14% Shell 0.69%

serverless-frontend-plugin's Introduction

serverless-frontend-plugin

Package and deploy any frontend with your serverless backend.

Installation

npm install --save-dev serverless-frontend-plugin

Implementation

  • Include this plugin in the plugins section of your severless.yml.
plugins:
  - serverless-frontend-plugin
  • Add your frontend build commands and set the working directory by adding the following to the custom section of your serverless.yml:
custom:
  serverless-frontend-plugin:
    distDir: frontend/dist
    build:
      cwdDir: frontend
      command:
        - npm
        - run
        - build
    distribution:
      acmCertificateArn: <your certificate arn>
      dnsName: <your-domain.com> # Route53 record value
      altDnsName: <another.your-domain.com> # Route53 record value
      hostedZoneName: <your-domain.com> # Route53 Hosted Zone Name

Options

  • mode: (string) Type of frontend hosting. Currently the only supported mode is cloudfront.
  • distDir: (string) The directory that gets uploaded and hosted as a static site. Defaults to frontend/dist.
  • build: (Map)
    • command: (string[]) Command and options as an array of strings. For example, ["npm", "run", "build"] Defaults to ["echo", "no", "frontend", "build", "command"].
    • cwdDir: (string) The directory from which to run the build.command. Defaults to ./frontend.
    • env: (Map) A key/value mapping of environment variables and values to inject into the frontend build.
  • stackName: (string) Name of the CloudFormation stack for the frontend. Defaults to <service-name>-<stage>-<region>.
  • bucket: (Map)
    • name: (string) Name of the S3 Bucket to upload the distDir to. Defaults to a generated name.
    • indexDocument: (string) Defaults to index.html.
    • errorDocument: (string) Defaults to index.html.
  • distribution: (Map)
    • dnsName: (string Required) A DNS name to use for this Cloudfront distribution. This is required and has no default values.
    • altDnsName: (string) Another DNS name to use for this Cloudfront distribution.
    • acmCertificateArn: (string, Required) AWS ACM Certificate Arn that covers the domain names listed in aliases.
    • hostedZoneName: (string) Name of the AWS Route53 Hosted Zone to create the Route53 records. Defaults to the value of dnsName.
    • mimeTypes: (Map) A key/value mapping of file extensions and mime types to override. For example:
    ...
      distribution:
        mimeTypes:
          html: text/html # default
  • offline: (Map)
    • command: (string[]) Command and options as an array of strings. For example, ["npm", "start"] Defaults to ["echo", "no", "frontend", "offline", "command"].
    • env: (Map) A key/value mapping of environment variables and values to inject into the frontend start command.
    • cwdDir: (string) The directory from which to run the offline.command. Defaults to ./frontend.

Offline Integration

This plugin seamlessly integrates with serverless-offline. Simply Add an offline configuration under custom.serverless-frontend-plugin in your serverless.yml. See offline options above.

Examples

See the test configs on Github for working examples. Just be sure to replace the following section in the serverless.yml:

# Replace this
plugins:
  - ../../../index.js

# With this
plugins:
- serverless-frontend-plugin

serverless-frontend-plugin's People

Contributors

rogersgt avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.