kindspells / astro-shield

Astro integration to enhance your website's security with SubResource Integrity hashes, Content-Security-Policy headers, and other techniques.
https://astro-shield.kindspells.dev
MIT License
56 stars 5 forks source link

devex: avoid the need for building twice when the only static resources are the ones from /public/ #37

Closed castarco closed 7 months ago

castarco commented 7 months ago

Problem statement

When relying on output server or hybrid, and some of our pages rely on static resources (scripts/stylesheets), it is possible that the developer must run astro build two times in a row because of how the "hashes module" is generated (at the end of the build process).

However, in some circumstances, that shortcoming is avoidable. The specific circumstances are easy to define: when the only static resources that are relied upon happen to exist before the build ends (that is, when those resources are the ones present in the /public/ directory).

At this time we are still not taking advantage of these circumstances when they are present.

Proposed solution