Derek Kershner
03/08/2022, 4:11 PM[id].tsx
).
• Have you thought about this?
• Do you think there is value and would SST have interest in such a thing? On the face of it, it would allow a simple, cheap entrypoint to Next.JS with capabilities more or less on par with something like CRA and Next.JS defaults and static exporting (not a SPA, but real static site). It would be devoid of features listed here.Derek Kershner
03/08/2022, 4:13 PMFrank
StaticSite
?Derek Kershner
03/08/2022, 6:40 PMFrank
Derek Kershner
03/08/2022, 6:42 PMDerek Kershner
03/08/2022, 6:42 PMFrank
Derek Kershner
03/08/2022, 6:44 PMFrank
NextjsStaticSite
or NextjsExportStaticSite
lol to make it less confusing with the existing construct.Derek Kershner
03/08/2022, 6:48 PMDerek Kershner
03/08/2022, 6:48 PMDerek Kershner
03/08/2022, 11:51 PMroutes-manifest.json
), and I need to get a value from it up into the CDK.
This doesn’t seem too bad to do from inside StaticSite
, but there is really no way to grab after build, but before deploy. Or I could do it outside, but then I would have to build twice. Guidance?Derek Kershner
03/09/2022, 5:19 AMroutes-manifest.json
into the CDK. I have tried a few methods, but am running into issues ranging from NPM not existing to not being able to run anything prior to super
. Aside from re-creating StaticSite
entirely, I am not sure where to go, but I bet you do.Derek Kershner
03/09/2022, 5:48 AMFrank
routes-manifest.json
in order to configure the CloudFront distribution accordingly?
I wonder if Lazy
helps in this case:
const site;
site = new StaticSite(this, "Site", {
path: "path/to/src",
buildOutput: "dist",
buildCommand: "npm run build",
cfDistribution: Lazy.any({
produce(context) {
const file = fs.readFileSync("path/to/routes-manifest.json");
return {
defaultBehavior: { ... },
additionalBehaviors: { ... },
};
}
}),
});
So inside Lazy.any
, if you reference site.s3Bucket
, then produce
will get called after site.s3Bucket
is created. At this point, the site has been built and routes-manifest.json
should exist.Derek Kershner
03/09/2022, 4:48 PMDerek Kershner
03/09/2022, 5:42 PMNextjsStaticSite
that extends StaticSite
. For now I will just publish within my org, but let me know how you would like to proceed.Derek Kershner
03/09/2022, 5:45 PMfileOptions
you use in ReactStaticSite
and ViteStaticSite
and what they mean?Derek Kershner
03/09/2022, 5:45 PMfileOptions: [
{
exclude: "*",
include: "*.html",
cacheControl: "max-age=0,no-cache,no-store,must-revalidate",
},
{
exclude: "*",
include: ["*.js", "*.css"],
cacheControl: "max-age=31536000,public,immutable",
},
]
Derek Kershner
03/09/2022, 6:08 PM