Skip to content

Latest commit

 

History

History
74 lines (65 loc) · 2.59 KB

override.mdx

File metadata and controls

74 lines (65 loc) · 2.59 KB

In this version of open-next, you could override a lot of the default behaviour.

For some real example of how to override each behaviour:

This means it could allow people to write their own custom open-next. For example you could create a custom withGcp plugin to allow to deploy open-next on GCP functions

A boilerplate for such a plugin could look like this (This is not real code):

import { BuildOptions } from "open-next/types/open-next";

function withGcp(config: TrimmedDownConfig): BuildOptions {
  return {
    default: {
        override: {
          wrapper: async () => (await import("./gcp-wrapper")).default,
          converter: async () => (await import("./gcp-converter")).default,
          incrementalCache: async () => (await import("./gcp-incremental-cache")).default,
          tagCache: async () => (await import("./gcp-tag-cache")).default,
          queue: async () => (await import("./gcp-queue")).default,
        },
        ...config.default,
    },
    functions: {
      // Same as default but for each splitted function
      //...
    }
    warmer: {
      override: {
        wrapper: async () => (await import("./gcp-wrapper")).default,
        converter: async () => (await import("./gcp-converter")).default,
      },
      invokeFunction: async () => (await import("./gcp-invoke-function")).default,
    },
    revalidate: {
      override: {
        wrapper: async () => (await import("./gcp-wrapper")).default,
        converter: async () => (await import("./gcp-queue-converter")).default,
      },
    },
    imageOptimization: {
      override: {
        wrapper: async () => (await import("./gcp-wrapper")).default,
        converter: async () => (await import("./gcp-converter")).default,
      },
      loader: async () => (await import("./gcp-object-loader")).default,
    },
  }
}

Using this plugin would look like this inside open-next.config.ts:

import { withGcp } from "./with-gcp";
const config = withGcp({
  default: {
    // ...
  },
});

module.exports = config;