npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@greenwood/plugin-adapter-netlify

v0.30.2

Published

A Greenwood plugin for supporting Netlify serverless and edge runtimes.

Downloads

404

Readme

@greenwood/plugin-adapter-netlify

Overview

This plugin enables usage of the Netlify platform for hosting a Greenwood application. For more information and complete docs on Greenwood, please visit our website.

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.

# npm
$ npm i -D @greenwood/plugin-adapter-netlify

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

# pnpm
$ pnpm add -D @greenwood/plugin-adapter-netlify

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