staticFileContent like embedFile#983
Conversation
|
Hi! |
I can't use I hope this makes sense. Maybe there is an alternative I overlooked. |
|
You should be able to produce the filepath without template haskell. It's just |
|
If you put a file in config/common or config/frontend, the contents are made available on the frontend. We do this by injecting the data as a base64-encoded string into the head of the page. You can use the functions in Would this functionality serve your purposes here? |
|
If I understand this change properly, it seems scary if the app has any large static files, no? If you were to drop, say, a 300MB video file into the static directory, emitting the entire contents of the video into your code at compile time might not work out too well. So if we want to do this, it should probably be controllable somehow. (But Ali's idea about using the existing config mechanism might also turn out to be good for your case here.) |
There is the "asset pass through" mechanism, though.
In principle, the config mechanism works. Only that my file isn't part of configuration in a meaningful way. I have a 770 kb file in json format that is the output of another haskell program, which I run prior to deployment. I.e. it contains expensively computed data that is then presented in the obelisk app. Using the config mechanism just implies copying this file twice: to 'development-dir/config/frontend/' and to 'deployment-dir/config/frontend'. The internal base64 encoding and decoding is unnecessary overhead. (Given the efficiency of While feasible, I would consider this an abuse of the config mechanism. |
It is just as scary as |
added function
staticFileContent, allows embedding static assets asByteStringduring compile time likeembedFiledoesI have:
developbranchhlint .(lint found code you did not write can be left alone)$(nix-build -A selftest --no-out-link)nix-build release.nix -A build.x86_64-linux --no-out-link(orx86_64-darwinon macOS)