prod_run.mjs 451 B

1234567891011121314151617
  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(
  7. ([env, val]) =>
  8. `${env}=${val.startsWith('"') && val.endsWith('"') ? val : `"${val}"`}`
  9. )
  10. .join("\n")
  11. fs.writeFileSync("build.env", envFileContent)
  12. execSync(`npx import-meta-env -x build.env -e build.env -p "/site/**/*"`)
  13. fs.rmSync("build.env")