prod_run.mjs 461 B

123456789101112131415161718
  1. #!/usr/local/bin/node
  2. import { execSync } from "child_process"
  3. import fs from "fs"
  4. const envFileContent = Object.entries(process.env)
  5. .filter(([env]) => env.startsWith("VITE_"))
  6. .map(([env, val]) => `${env}=${
  7. (val.startsWith("\"") && val.endsWith("\""))
  8. ? val
  9. : `"${val}"`
  10. }`)
  11. .join("\n")
  12. fs.writeFileSync("build.env", envFileContent)
  13. execSync(`npx import-meta-env -x build.env -e build.env -p "/site/**/*"`)
  14. fs.rmSync("build.env")