Open thangngoc89 opened 3 years ago
On the other hand, using a build time approach, one could inline the content of small images directly to string like webpack/rollup does. Or one could write a ppx that does different things based on the arguments. But I don’t know how to write ppxes that is more complex than replacing a string with a string 😂
On the topic of hashing, rollup uses
Update:
dream is using mirage-digestif but it's library for cryptographic hashes. I would prefer a non-cryptographic hash for tasks like this
It all looks feasible. It looks largely independent from Dream itself. We would basically just call out from templates (or anywhere else) to some library to figure out the real name of an asset, right? I guess that library would need to know how to read the output of the hasher, and serve as the "runtime library" linked into server deployments.
@aantron yes. It should work independent of dream but I only interested in build for dream right now. So I want to open discussions here and looking for comments/feedbacks on the design
As I said on Discord, I wanted to write a ppx for static assets hashing and cache bursting. The idea is like this:
style.css
tostyle.content_hash.css
and returnstyle.content_hash.css
However after careful consideration, I decided that it would be a runtime library rather than build time. Here are some reasons I can think of:
What I am proposing would be configuration file in JSON format like this:
How is this loaded is up to the implementor, could be a file during application start up, could be via POST request.
TODO:
What do you think?