-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add output-dir option #65
Conversation
(web-path {:protocol "http:" | ||
:output-dir "resources/public/js/saapas.out" | ||
:asset-path "js/saapas.out"} | ||
"resources/public/js/saapas.out/saapas/core.js"))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a real use case?
Writing files to resources directory doesn't make much sense, and even if it was the target directory it wouldn't make much sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the same use case whether or not the "resources/" is there.
Thanks. This will need some thinking as I would prefer not to break current behavior and I don't yet completely understand the use case for this. Can you describe the use case? I guess example project would be really useful. This takes us sadly closer to declarative Leiningen configuration where users have to configure paths to multiple plugins to get them work closer. Preferred solution in Boot would be to infer the configuration from files in fileset created by user (.cljs.edn), from files created by other tasks, or from metadata. |
From reading the linked pull request, this is more about where the directory/file is mounted as seen by the browser than where you want to output on the local file system? |
I see your point about having a redundant configuration, and I do agree it is not a good thing, but it is better than a non-working configuration. In my use I have found that: (serve :dir "resources/public")
(reload :ids #{"project"})
(cljs :compiler-options {:asset-path "js/project.out"})
(target :dir #{"resources/public/js"}) does not reload. (Don't get hung up on "resources/", the part that makes this not work is "js".) And similarly: (reload :ids #{"project"} :asset-path "js/project.out")
(cljs :compiler-options {:asset-path "js/project.out"}) just makes things worse. The two textually adjacent uses of The ultimate motivation for this is development with nginx. I'm writing a clojurescript app that needs to access a backend not in the same project, so to make everything appear to be at the same domain in development, I use nginx to reverse-proxy the backend and serve static files out of "resources/public". (I'm also using HTML5 history which doesn't work with the baked-in webserver as best I can tell, so there are multiple reasons to bring in nginx here.) With this setup, loading the js works the first time, but reloading doesn't work, because the paths that get sent over the websocket are foobarred and can't be fixed by any existing option. Yes, it is a backwards-incompatible change and would require a corresponding version bump if accepted, but the current situation:
All-in-all, it is just better to keep separate concepts (asset-path, output-dir) separate. If it is possible to avoid the redundant configuration by inferring the necessary config from elsewhere, I'd be happy to rewrite this patch to do so, but I would appreciate some kind of pointer in the right direction. |
@esessoms First, not directly related to this PR, but boot-http (as of 0.7.3) supports a |
Thanks @pandeiro I will give |
Example project, as requested: |
@esessoms Not sure if it helps at all here, but you should not use Objective with boot-cljs + reload is to work automatically when user is adhering to some convetions, like serving files from classpath. Some option can be provided for other use cases, but I consider that secondary objective. HTML5 is such special case which I guess will require some configuration. |
Also, as quick fix, I'm open to adding new options, but it would be much preferred if they didn't break existing set ups (i.e. rename existing option). |
Yes, I keep that in mind. One solution I've been talking with @micha (for over a year now, probably) is having some kind of Possible asset-path could even be infered from the relative path of file inside fielset, like boot-cljs does with |
The old asset-path option had the opposite behavior of the option of the same name in the clojurescript compiler. It was performing a role similar to clojurescript's output-dir, and there was no way to get the expected asset-path behaviour. See https://github.com/clojure/clojurescript/wiki/Compiler-Options This commit adds a new option cljs-asset-path that corresponds to the clojurescript asset-path.
@Deraen I do not doubt that your advice on proper usage is correct. I'll just note that it contradicts the boot faq, the boot-cljs example project, and the recommended tutorial. That is, all the documentation is out of date in this respect. https://github.com/boot-clj/boot/wiki/FAQ But I have restored the old |
@esessoms You are correct, I've been slacking with documentation, I guess we should really support both cases, and with proper implementation it shouldn't really matter if one serves files from classpath or filesystem. Saapas and Tenzing serve files from classpath and they listed in the same list as modern-cljs so not all documentation/examples are "wrong" :) |
How is this issue going now? |
The changes look good now. I will still need to find some time to test this with few projects before a release. |
Well, I found some time quite soon :) This is now deployed as 0.4.6. |
👍 |
(if (= "file:" protocol) | ||
(.getCanonicalPath (io/file target-path rel-path)) | ||
(str | ||
(if cljs-asset-path (str cljs-asset-path "/") "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Deraen @esessoms I think this introduced a bug: paths are no longer starting with /
breaking reloading from pushState locations. Should this line perhaps be:
(str cljs-asset-path "/" ...)
So that the slash is always present?
The old asset-path option had the opposite behavior of the same option
in the clojurescript compiler. It was performing a role similar to
clojurescript's output-dir, and there was no way to get the expected
asset-path behaviour.
See https://github.com/clojure/clojurescript/wiki/Compiler-Options
This commit renames the old asset-path to output-dir, and adds a true
asset-path option.