Code Monkey home page Code Monkey logo

next-aws-lambda-webpack-plugin's Introduction

next-aws-lambda-webpack-plugin

npm puppeteer package integration test next@latest

This plugin will generate aws-lambda compatible function for each Next.JS pages. After that, you can to use theses functions with the AWS cloudformation template or/and AWS serverless template.

This plugin use next-aws-lambda package, create by and for the serverless community โค๏ธ.

๐Ÿ‘‰ Here a full implementation example (step by step)

next-aws-lambda-webpack-plugin

Requirement

  1. Use Next.JS CLI for build your project (next build)
    • The configuration file next.config.js must use target: 'serverless'.
  2. Use SAM or AWS CLI cloudformation for your deployment.

Next.JS compatibility

Next.JS Version Tests
canary integration test next@canary
latest integration test next@latest
10.0.5 integration test next@latest
9.5.0 integration test next@latest
9.4.0 integration test next@latest

Install

Use npm :

npm install --save-dev next-aws-lambda-webpack-plugin

Add the plugin to the Next.JS (next.config.js) configuration file.

Plugin Arguments Required Description
nextJsConfig YES Next.JS config retrieve from#next.config.js, see example below.
options NO see options

Example:

const GenerateAwsLambda = require('next-aws-lambda-webpack-plugin');

module.exports = {
    target: 'serverless',
    webpack: (config, nextConfig) => {
        config.plugins.push(new GenerateAwsLambda(nextConfig));
        return config
    },
};

Options

Plugin Options Required Default Description
distDir No "out_lambda" Custom lambda build directory.
prefix No "l" Prefix apply to each lambda directory.
pages No [] A whitelist who specified SSR pages. If empty array is specified all pages are generated.

Example:

//...snip...
new AwsLambdaGenerator(nextConfig,{
    distDir: 'lambda_build'
})
//...snip...

Architecture Example

๐Ÿ‘‰ Go to example

cloud-front-distribution-example

next-aws-lambda-webpack-plugin's People

Contributors

dependabot-preview[bot] avatar vincent-herlemont avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

next-aws-lambda-webpack-plugin's Issues

next-aws-lambda is out of date

Hi!

The package used by this package, next-aws-lambda is out of date. It takes a event.requestContext.path but the currently returned value by AWS is event.requestContext.http.path.

The next-aws-lambda package has no github page and is unmaintained.

I have found a maintained alternative: https://github.com/vendia/serverless-express. It is used by a lot of people and there is a blog post on it on amazon.com as well (https://aws.amazon.com/blogs/compute/going-serverless-migrating-an-express-application-to-amazon-api-gateway-and-aws-lambda/). You don't have to use express with it, it takes a (req, res) => {} function as a handler as well.

Misleading schematic

The schematic is somewhat misleading. https://github.com/vincent-herlemont/next-aws-lambda-webpack-plugin/blob/master/assets/cloud-front-distribution-example.png?raw=true

parameter.js in fact sits behind the API Gateway as a ฦ› resolver and Cloudfront is just serving the static resources via S3. There is no connection from CF to parameter.js at all and certainly isn't in the yellow cloud front.

Might be an idea to use one of the AWS diagramming tools to draw out what's actually created.

License

Please add a license (MIT?).

Why does this work with Next.js 10?

Hi Vincent,

Your webpack plugin looks really interesting! However, I am surprised to see it works with Next.js 10 whereas you say using "next-aws-lambda" under the hood and they claim to support Next.js 9 only.

How is it possible your webpack plugin is working with Next.js 10?

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.