hepek
hepek copied to clipboard
Macro for static resources
A very cool feature would be to have a macro that reads from src/main/public
path and builds a tree of Resource
s.
E.g. if you have this tree:
site
├───images
│ favicon.ico
├───scripts
│ main.js
└───styles
main.css
it would generate this:
object resources {
object site {
object images {
val favicon_ico = resource("favicon.ico")
}
// ... etc
}
}
Then you could say just resources.site.image.favicon_ico.ref
to get the path to favicon.ico
. 😃
Since .ref
returns a relative path, this would be very helpful.
Doesnt have to be a macro.. just a simple plugin/task
https://www.scala-sbt.org/1.x/docs/Howto-Generating-Files.html
https://mill-build.com/mill/Extending_Mill.html#_example_customizing_the_meta_build generatedSources ..
Done in https://github.com/sake92/sbt-hepek/commit/534c157abe49861188c6f83f9acf8390842b6dea https://github.com/sake92/mill-hepek/commit/a1fec9f515d4f254eb89907bc5eab9d0a6c4b9e3