Skip to content
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

Helpful classpath adding ancestor of target directory #221

Closed
danielcompton opened this issue Nov 23, 2019 · 2 comments
Closed

Helpful classpath adding ancestor of target directory #221

danielcompton opened this issue Nov 23, 2019 · 2 comments
Labels
bug Something isn't working

Comments

@danielcompton
Copy link

danielcompton commented Nov 23, 2019

In development we use Figwheel to build our ClojureScript resources. We serve target/resources/acme/public for our static assets and build to target/resources/acme/public/js/frontend.js. We have target/resources added as a path in our deps.edn file.

I think having acme between resources and public is confusing the helpful classpath handling. When we build, Figwheel looks for target/resources/acme as a directory on the classpath, and doesn't realise that target/resources is on the classpath.

[Figwheel] Validating figwheel-main.edn
[Figwheel] figwheel-main.edn is valid \()/
[Figwheel:WARNING] Attempting to dynamically add "target/resources/acme" to classpath!
[Figwheel:WARNING] Target directory "target/resources/acme" is not on the classpath
[Figwheel:WARNING] Please fix this by adding "target/resources/acme" to your classpath
 I.E.
 For Clojure CLI Tools in your deps.edn file:
    ensure "target/resources/acme" is in your :paths key

 For Leiningen in your project.clj:
   add it to the :resource-paths key

[Figwheel] Compiling build app to "target/resources/acme/public/js/frontend.js"
[Figwheel] Successfully compiled build app to "target/resources/acme/public/js/frontend.js" in 4.418 seconds.
[Figwheel] Watching paths: ("src/cljs" "src/cljc") to compile build - app
[Figwheel] Starting Server at http://localhost:9500

(fw-util/dir-on-classpath? "target/resources")
=> "<redacted>/acme-app/target/resources"
(fw-util/dir-on-classpath? "target/resources/acme")
=> nil

Here is our config:

{:id "app"
 :options {:main acme.frontend.main
           :preloads [day8.re-frame-10x.preload]
           :parallel-build true
           :output-to "target/resources/acme/public/js/frontend.js"
           :output-dir "target/resources/acme/public/js/frontend.out"
           :optimizations :none}
 :config {:watch-dirs ["src/cljs" "src/cljc"]
          :css-dirs ["target/resources/acme/public/css"]
          ;; We make our resources go to target/resources/acme instead
          ;; of target/resources. Figwheel doesn't understand this and
          ;; tries to add target/resources to the classpath a second time.
          ;; Disabling helpful-classpaths will prevent this, though we still get
          ;; a warning from Figwheel that the directory is not on the classpath.
          :helpful-classpaths false}}

We are turning off :helpful-classpaths, but I think this might actually be a bug? I could be wrong though.

@bhauman
Copy link
Owner

bhauman commented Nov 23, 2019

Yes this looks buggy to me.

Also keep in mind that you can set :target-dir to target/resources/acme and then use the default output-to and output-dir this might make things smoother in the meantime.

@bhauman bhauman added the bug Something isn't working label Nov 23, 2019
werenall pushed a commit to biotz/figwheel-main that referenced this issue Dec 4, 2020
@bhauman
Copy link
Owner

bhauman commented Feb 11, 2021

I've looked at this again and I don't think it was a bug.

"target/resources/acme" needs to be on the classpath because Jetty serves the "/public" directory not the "/*/public" directory.

Sorry for not looking at this sooner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants