Devin
01/27/2022, 4:02 PM<scripts src="my-cool-embed.bundled.js"></script>
Is that just some kind of minified JS that’s stored in an s3 bucket and the access is by… I guess URL? I don’t really understand the architecture of how something like that would work.thdxr
01/27/2022, 4:03 PMthdxr
01/27/2022, 4:03 PMthdxr
01/27/2022, 4:03 PMrollup
to bundle your code into various formatsDevin
01/27/2022, 4:04 PMDaniel Gato
01/28/2022, 10:46 PM<our-viewer id="abc"></our-viewer>
<script src="<https://cdn.example.com>" async></script>
Our script will find and initialise that component.
We build our codebase with webpack (or similar) and then copy it to s3 in a version folder: /public/v1.0.1/main.js
Then we have a cloudfront distribution that points there. We have a folder /latest that points to the latest version and that we change the “target” every deployment
We keep versions in case some new version would introduce some unwanted side effect. This allows the user to target another version if needed
<script src="<https://cdn.example.com/v1.0.0/main.js>" async></script>
At the moment, this company does not use SST, lately I have tried SST intensively in order to migrate that company to it and so far, I have tried a static Site - works ok but I lost the versioning.
We have tried as well a simple bucket + a Cloudfront distribution and using BucketDeployment construct from cdk. Works well. We haven’t finish the whole implementation yet.
One gotcha - BucketDeployment has changed and now you have to allow PutObjectAcl to your bucket for it to work. We do it this way:
this.modelsBucket.s3Bucket.grantPut(new iam.AnyPrincipal());
this.modelsBucket.s3Bucket.grantPutAcl(new iam.AnyPrincipal());
Not sure how good this is, but at least it works now.Devin
01/29/2022, 1:01 AM