0.29.3 • Published 3 days ago

@greenwood/plugin-adapter-netlify v0.29.3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 days ago

@greenwood/plugin-adapter-netlify

Overview

This plugin enables usage of the Netlify platform for hosting a Greenwood application.

This package assumes you already have @greenwood/cli installed.

Features

In addition to publishing a project's static assets to the Netlify CDN, this plugin adapts Greenwood API routes and SSR pages into Netlify Serverless functions using their custom build approach

This plugin will automatically generate a custom _redirects file to correctly map your SSR page and API route URLs to the corresponding Netlify function endpoint (as a rewrite). You can continue to customize your Netlify project using your netlify.toml file as needed.

Note: You can see a working example of this plugin here.

Installation

You can use your favorite JavaScript package manager to install this package.

examples:

# npm
npm install @greenwood/plugin-adapter-netlify --save-dev

# yarn
yarn add @greenwood/plugin-adapter-netlify --dev

You will then want to create a netlify.toml file at the root of your project (or configure it via the Netlify UI), updating each value as needed per your own project's setup.

[build]
  publish = "public/"
  command = "npm run build" # or yarn, pnpm, etc

[build.processing]
  skip_processing = true

[build.environment]
  NODE_VERSION = "18.x" # or pin to a specific version, like 18.15.0

Set the AWS_LAMBDA_JS_RUNTIME environment variable in your Netlify UI to the value of nodejs18.x.

Usage

Add this plugin to your greenwood.config.js.

import { greenwoodPluginAdapterNetlify } from '@greenwood/plugin-adapter-netlify';

export default {
  ...

  plugins: [
    greenwoodPluginAdapterNetlify()
  ]
}

Optionally, your API routes will have access to Netlify's context object as the second parameter to the handler function. For example:

export async function handler(request, context = {}) {
  console.log({ request, context });
}

Please see caveats section for more information on this feature. 👇

Netlify CLI / Local Development

This plugin comes with the Netlify CLI as a dependency to support some local development testing for previewing a Netlify build locally. Simply add a script like this to your package.json

{
  "serve:netlify": "greenwood build && netlify dev"
}

Then when you run it, you will be able to run and test a production build of your site locally.

Please see caveats section for more information on this feature. 👇

Caveats

  1. Edge runtime is not supported (yet).
  2. Netlify CLI / Local Dev
0.30.0-alpha.2

3 days ago

0.29.3

5 days ago

0.30.0-alpha.1

2 months ago

0.30.0-alpha.0

2 months ago

0.29.2

4 months ago

0.29.1

5 months ago

0.29.0

6 months ago

0.29.0-alpha.6

6 months ago

0.29.0-alpha.5

7 months ago

0.29.0-alpha.4

8 months ago

0.29.0-alpha.3

9 months ago

0.29.0-alpha.2

9 months ago