processing / p5.js-website

New p5.js website!
http://p5js.org
MIT License
18 stars 92 forks source link

Use import.meta.env + ENV file so hydrated components work #629

Closed davepagurek closed 2 weeks ago

davepagurek commented 2 weeks ago

Resolves https://github.com/processing/p5.js-website/issues/627

Adds @shibomb's check to see if process.env is defined for node environments, but also falls back on import.meta.env for non-SSR components hydrated in the browser. To do this, the env vars are written to a .env file that Astro reads, and the vars that need to be read in the browser have to have a PUBLIC_ prefix for Astro to pass them through.

Also makes more schema things optional for dev builds and corrects the cleanup script from removing those changes (it was cleaning up the whole reference folder instead of just the content in reference/en/, oops)