Does anyone have experience using SST to build Chr...
# help
s
Does anyone have experience using SST to build Chrome browser extensions? I'm working on a project that has a Chrome extension and static site that both talk to the same backend. I'm struggling to get my development and production environments setup. I've added the browser extension to my SST project as a ReactStaticSite. Editing the manifest.json file in the Public folder to match the Chrome Extension requirements works fine. I can get everything to work when I'm developing and using "npx sst start" and the environment variables swap in using the sst-env command in the start script. However, when I try to deploy, the variables don't get substituted like I expect. The code in the build directory of my extension still has {{ REACT_APP_...}} instead of the variables I need (e.g. API endpoint). However, if I pull the deployed code down from S3 the placeholder substitutions are made appropriately. I'm a noob at all this, so I think I have something wrong with my mental model of how it should work. Any pointers from somebody that has done browser extension development would be much appreciated. Thanks!
t
yeah so ReactStaticSite is meant for things published to cloudfront
we need to do the replacement after it's deployed because only then do we have the values to replace
so we actually upload your files first, then replace them all in a hook that runs after
if you do want SST to handle this my suggestion would be to download the uploaded bundle from s3 as a final step before you upload to chrome. Otherwise you probably can just have sst not handle anything related to the extension
s
Thanks! That's really helpful - I understand better now what's going on under the hood. I'll look into keeping the projects separate. I assume that means I'll need to hard code in the dev/prod parameters I need in the extension (the API URL and the Cognito IDs). Is there any documentation on when those change?
m
I'm building a browser extension but SST isn't involved in the extension itself. I'm using webpack (sadly) for that part
cognito IDs change when you make a new userpool
s
Thanks Mischa - nice to have that external data point. I did split the extension out of my SST repo and life is easier. If you've found any resources that make life easier for extension developers, I'd love to take a look.
m
i'll sell you my webpack config... j/k
note that it is ESM
s
Thanks! Much appreciated.