UNPKG

@aziontech/opennextjs-azion

Version:
16 lines (15 loc) 758 B
/** * This code was originally copied and modified from the @opennextjs/cloudflare repository. * Significant changes have been made to adapt it for use with Azion. */ import fs from "node:fs"; import path from "node:path"; import { extractProjectEnvVars } from "../utils/index.js"; /** * Compiles the values extracted from the project's env files to the output directory for use in the worker. */ export function compileEnvFiles(buildOpts) { const envDir = path.join(buildOpts.outputDir, "azion"); fs.mkdirSync(envDir, { recursive: true }); ["production", "development", "test"].forEach((mode) => fs.appendFileSync(path.join(envDir, `next-env.mjs`), `export const ${mode} = ${JSON.stringify(extractProjectEnvVars(mode, buildOpts))};\n`)); }