I think the previous question was interpreted in the context of single page applications where it doesn't make sense to have more than one output file.
If you need different behaviors in separate web pages, I suggest you have an entry namespace for each webpage, using the :main
option:
:cljsbuild {:build [{:id "login"
:main my-login.entry
:output-to "resources/public/js/login.js"
:optimizations :advanced}
{:id "feed"
:main my-feed.entry
:output-to "resources/public/js/feed.js"
:optimizations :advanced}]}}
And then require those files on each webpage.
This approach is worth the trouble if my-feed.entry
and my-login.entry
will require different code, and it would be a waste to deliver all the code for feed
also to login
. If the behavior is almost the same, and is just a matter of an argument, or one function call, your suggestion is fine.