Hrm. How does ```sst.ReactStaticSite``` allow envi...
# help
g
Hrm. How does
Copy code
sst.ReactStaticSite
allow environment variables to be passed to the frontend app? Does it depend on a particular setup for production deployment? (i.e. availability of scripts, webpack env variable / define plugin, etc
f
Hey @Gjorgji Kjosev, say you set environment to this:
Copy code
new ReactStaticSite(this, "ReactSite", {
  path: "path/to/src",
  environment: {
    REACT_APP_API_URL: api.url,
  },
});
1. At build time, SST build runs
REACT_APP_API_URL="{{ REACT_APP_API_URL }}" npm run build
2. After
api
is deployed,
{{ REACT_APP_API_URL }}
is replaced with the deployed value in all .html and .js files
g
Got it, so any
build
script that takes advantage of environment variables should work.
ty
f
Yup it should. Lemme know if it doesn’t.