Mr.9715
06/11/2021, 9:31 AMfind . -type f -exec grep -Iq . {} \; -exec sed -i 's/Harshit/harshit/g' {} +
Frank
sst.StaticSite
where we replace ie MY_API_URL
with the deployed endpoint of sst.Api
Jay
Jay
Mr.9715
06/11/2021, 6:10 PMMr.9715
06/11/2021, 6:25 PMJay
Jay
Mr.9715
06/11/2021, 9:06 PMsed.
Check out the repo, and try it yourself.Mr.9715
06/11/2021, 9:08 PMRyan
06/15/2021, 2:09 PMif (stage === 'prod') { ... }
was kindly removed because stage
was a constant and it equalled #{$stage}
.
Replacing before compile is time consuming (well because you have to recompile the App!). And then you have a different build between QA and Prod, and ideally you'd want the same build so there isn't chance of something wonky in a different build. (Kinda minor issue though IMO).
Runtime configuration is another option, however it means a roundtrip before your app can start (depending how you do it). But you can build this to be pretty optimal, or you can embed it in your index.html or something else. Then you have to write some code to handle reading those values. So you treat the some vars as compile time environment, and other ones as runtime environment.
I think as far as StaticSite
is concerned, a find/replace would be cool. I just currently dump everything in a json file that the frontend expects right before calling new StaticSite
. With find/replace I could just point it at a template of said file. Optimizers are more of a frontend issue and not really a seed issue I think, so a generic mechanism would be cool.Jay
Ryan
06/16/2021, 6:10 AMenvironment.prod.ts
import config from './config-prod.json';
export const environment = {
production: true,
apiUrl: config.apiUrl
};