How to use the next-server/dist/lib/constants.PHASE_PRODUCTION_BUILD function in next-server

To help you get started, we’ve selected a few next-server examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github danielcondemarin / serverless-next.js / packages / serverless-nextjs-plugin / lib / parseNextConfiguration.js View on Github external
let nextLoadConfig;
let PHASE_PRODUCTION_BUILD;
try {
  nextLoadConfig = require("next-server/dist/server/config").default;
  PHASE_PRODUCTION_BUILD = require("next-server/dist/lib/constants")
    .PHASE_PRODUCTION_BUILD;
} catch (e) {
  // https://github.com/danielcondemarin/serverless-next.js/issues/157
  // Some files were moved in the dist/ directory in next.js 9.0.6
  // check the new location if the old location failed.
  nextLoadConfig = require("next/dist/next-server/server/config").default;
  PHASE_PRODUCTION_BUILD = require("next/dist/next-server/lib/constants")
    .PHASE_PRODUCTION_BUILD;
}

const s3Urls = require("@mapbox/s3urls");
const createError = require("../utils/createError");

module.exports = nextConfigDir => {
  if (typeof nextConfigDir !== "string") {
    throw createError("Provide a valid next.config file path");