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

Improve docs regarding Leiningen uberjar and resource paths #138

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

olieidel
Copy link

Problem

  • In Leiningen, including target in :resource-paths (in project.clj) is good because we want to serve compiled js files and figwheel-main outputs those to target.
  • For uberjars however, this poses a problem as the half-baked uberjar is also in target and will try to include all resources which are, you guessed it, also in target. The uberjar will be infinitely large.

Solution

  • For Leiningen, change the figwheel-main config instead; set :output-dir to something else (e.g. resources/public/js) and drop the target in :resource-paths (in project.clj).
  • Add that to the readme.
  • Add notes to the docs in relevant places.

Closes #134.

@bhauman
Copy link
Owner

bhauman commented Jan 29, 2019

Actually the better way to do this as I mentioned in the issue, is to set :target-dir "resources/public" as it will adjust all the internally calculated paths ie. :output-dir, :output-to and :asset-path as needed. Sorry I thought that this was clear from my response in the issue.

@devurandom
Copy link

devurandom commented Mar 6, 2019

Actually the better way to do this as I mentioned in the issue, is to set :target-dir "resources/public" as it will adjust all the internally calculated paths ie. :output-dir, :output-to and :asset-path as needed. Sorry I thought that this was clear from my response in the issue.

So in my dev.cljs.edn I add an entry :target-dir "resources/public" to the map (not to its metadata)? How do I adjust the :resource-paths in project.clj so that the files generated by figwheel will be available in the expected path? How do I prevent mixing "original" files and generated files in this setup (with the current recommendation, I have "original" files in resources and generated files separately in target)?

I tried to build my css and js files into target/resources. Would that be a viable option for the general public? How would you set this up properly, i.e. how would you phrase the recommendation for the figwheel README?

@bhauman
Copy link
Owner

bhauman commented Mar 7, 2019

You add will need to add :target-dir to the metadata as it's a figwheel option not a CLJS compiler option. You would then remove any reference to :resource-paths in your project.clj.

@ghost
Copy link

ghost commented Mar 7, 2019

I now went with this setup:

dev.cljs.edn:

^{:target-dir "target/resources"
  :css-dirs ["target/resources/public/css"]
  ...}
{...}

project.clj:

{...
  :source-paths ["src/clj" "src/cljs"]
  :target-path "target/%s/"

  :resource-paths ["target/resources"
                   "resources"]

  :clean-targets ^{:protect false} [:compile-path :target-path]

  :profiles
  {:dev
   {...
    :source-paths ["dev"]
    :resource-paths ^:replace ["target"
                               "target/resources"
                               "resources/dev"
                               "resources"]}
   ...}
...}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants