This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-11-19
Channels
- # bangalore-clj (1)
- # beginners (8)
- # boot (102)
- # cider (1)
- # clara (14)
- # cljs-dev (2)
- # cljsrn (2)
- # clojure (49)
- # clojure-poland (3)
- # clojure-russia (4)
- # clojure-serbia (1)
- # clojure-spec (5)
- # clojure-ukraine (1)
- # clojurescript (181)
- # core-async (4)
- # cursive (2)
- # datomic (7)
- # dirac (34)
- # figwheel (3)
- # fulcro (21)
- # hoplon (5)
- # om (1)
- # parinfer (4)
- # planck (27)
- # re-frame (30)
- # reagent (11)
- # rum (6)
- # shadow-cljs (22)
- # spacemacs (4)
- # unrepl (26)
Hello, I'm new to boot and am attempting to try some ideas that haven't worked well with lein
... I'm attempting to build an app with multiple targets, i.e. an isomorphic app with a cljs :server
target (that targets nodejs) and a cljs :client
target (that targets the browser). The interesting part that the two target may have namespaces that are shared and namespaces that are conflicting. I thought that pods would be the ideal way to isolate that two builds from each other, however I can't figure out how to run tasks within a pod... is it a good idea or should I use something like degree9/boot-exec
?
Any help or advice would be greatly appreciated, I have a sample project here: https://github.com/au-phiware/boot-isomorphic
@au-phiware that’s not really what I designed boot-exec for, it’s for shelling out to other executables
http://GitHub.com/Degree9/meta has an example of a client/server setup both using cljs
I noticed, you have a boot
task... https://github.com/degree9/boot-exec/blob/master/src/degree9/boot_exec.clj#L119
thanks for the pointer, I'll check it out
That’s just a proof of concept task, doesn’t have any real purpose
You are looking for boot-multibuild
However usually I refactor before attempting that approach, it’s not really needed for dual cljs projects
reading meta's readme... wish I'd found that months ago, sounds like a great stack!
It works well enough, but has limited documentation
The goal was a simple app in under 1 minute, which usually takes a few attempts to get running
I think I'd prefer to just pilfer some of its ideas anyway 🙂
Yeah thats probably best until it hits a stable version
I want to make some resources of a webjar (fonts/images) available on the class path. Can anyone give me a hint of how to do that using boot?
@freakinruben as long as the webjar is on the classpath, you should see your assets on the files, you can append the target
task at the end of the chain for seeing where they are located (or (show :fileset true)
)
the assets are inside the webjar, in my dependencies I have [org.webjars.bower/semantic "2.2.13"]
(show :fileset true)
only shows the files that are actually in my project
(show :classpath true)
shows that the jar is on the classpath /Users/myhomefolder/.m2/repository/org/webjars/bower/semantic/2.2.13/semantic-2.2.13.jar
@freakinruben I am working on semantic UI and boot as well
I am really find it hard to use less4clj
because it seems like the Java implementation is very limited compared to the JS one
Ah I see, I’m still exploring the boot-niverse and besides compiling semantic, I haven’t run into lots of complications with less4clj
I think semantic-ui is the toughest thing I could find in my quite long experience with boot...not boot's fault...
the task is actually very easy:
(deftask include-semantic
"Compile and prepare the css files"
[]
(comp
;; (sift :add-jar #{['cljsjs/semantic-ui #"cljsjs/semantic-ui/common/.*\.css"]})
(sift :move {#_#"cljsjs/semantic-ui/common/(.*\.css)" #_"css/$1"
#"semantic-ui-less/definitions" "css/definitions"
#"semantic-ui-less/themes" "css/themes" ;; need this here for less
#"semantic-ui-less/_site" "css/_site"
#"semantic-ui-less/semantic.less" "css/semantic.less"
#"semantic-ui-less/theme.less" "css/theme.less"})
(less)
(sift :move {#"css/themes/" (str serve-dir "themes/")})
(sift :move {#"css/" (str serve-dir "css/")})))
but a lot of warnings are coming out of that
@freakinruben (io/resource “path/to/file/in/jar”)
should work IIRC
I am even thinking of dropping less
compilation completely and just use css
I find that when using Tachyons I often don’t have the need for a preprocessor, not always an option though
what I will try today is to use https://github.com/degree9/boot-npm in order to use lessc
for compilation
@richiardiandrea if you have any issues let me know!
@richiardiandrea you are probably looking for https://github.com/degree9/boot-npm/blob/master/src/degree9/boot_npm.clj#L76
@flyboarder oh ok, I see already an issue in what I wanted to do
my task will be in a watch
and I wouldn't want to install the package every time
it wont reinstall
since it’s already in the managed folder, however it will check every time
oh cool
I have plans for a restartable task, basically something more generic than what is in boot-nodejs
cool thanks
it is good then for now, trying 😄
@richiardiandrea thanks a lot, this seems to do the trick for what I want:
(deftask include-semantic-assets
"Copy assets like fonts and images from semantic-ui to classpath"
[]
(comp
(sift :add-jar #{['org.webjars.bower/semantic #"dist/themes"]})
(sift :move {#"META-INF/(.+)/dist/themes" "public/themes"})))
@freakinruben yeah that works, however let me know what you get from compiling, I did not get themes when switching, say, from default
to material
here
same here… default works fine (one warning), but with material it grows to about 18 warnings and a not really functioning css
yeah...
less then optimal would be to use a non-java less compiler.. haven’t tried anything like that with boot
yeah I am trying exactly that
@freakinruben not for preprocessing however I use boot with external apps all the time
works well, they get their own managed folder which gets added to the fileset
@flyboarder one question I have is what is the pattern you use if you have a file from the fileset that needs to be passed as parameter to npm/exec
...maybe I should actually use boot-exec
here
@richiardiandrea as it currently stands boot-exec expects files to be in the root of a project, or passed in via task arguments
Via a wrapper task
ok so you actually need to execute the exec
task yourself inside the wrapper
Correct
Boot-npm is an example of this
@richiardiandrea so if your files exist only on the fileset (resources Etc.) you will want a task that copies them into a tmp dir then passes that tmp dir to the exec task
You can wrap that as a single task
Boot-exec can support cache and temp directories which are boot managed or absolute paths
@flyboarder should I see the std output of the command?
ok cool so then I am doing it wrong 😄
@richiardiandrea are you proving a :directory
or :cache
option?
no for now it is just a call to exec/exec :process "lessc"
@richiardiandrea ok so that will run lessc in a tmp dir
which is probably empty
uhm I am passing (exec/exec :process "lessc" :arguments [( .getAbsolutePath less-tmp-file) (.getAbsolutePath compiled-file)])
oh that should work, since the arguments are absolute
yeah I was thinking that would work, I am probably not invoking it correctly
given its middleware nature
(let [handler (exec/exec :process "lessc" :arguments [( .getAbsolutePath less-tmp-file) (.getAbsolutePath compiled-file)])]
(handler new-fs))
I would enable debug mode on boot to see exactly which arguments are being passed in
yeah it is not even called
right, I need on more call
Magic!
(let [mw (exec/exec :process "lessc" :arguments [( .getAbsolutePath less-tmp-file) (.getAbsolutePath compiled-file)])
handler (mw identity)]
(handler new-fs))
ardi/git/ar-website/dk2/alhi8w/css/blog.css
Executing Process: lessc
Executing Process with arguments: ["/home/arichiardi/.boot/cache/tmp/home/arichiardi/git/ar-website/dk2/fwjp2k/css/blog.main.less" "/home/arichiardi/.boot/cache/tmp/home/arichiardi/git/ar-website/dk2/alhi8w/css/blog.css"]
Process failed with...:
null
Process completed successfully...
lol ok so failed with null
means it couldn’t find the binary you are trying to execute
I have an issue created for that, it should fail the build entirely
oh nice at least we know what is failing
but right now it passes on non-zero error codes
when I use npm/exec
it is better
Process failed with...:
npm ERR! code E404
npm ERR! 404 Not Found: lessc@*
npm ERR! A complete log of this run can be found in:
npm ERR! /home/arichiardi/.npm/_logs/2017-11-19T21_54_55_866Z-debug.log
Process completed successfully...
Executing Process: lessc
Process failed with...:
null
oh right, it is less
and....works!
:thumbsup:
uhm...actually not quite...but getting there
I should really put together a boot-css task with a bunch of preprocessors out-of-the-box
BOOM! 💥
@richiardiandrea so there is also a :process
option for npm/exec when the exec is different than the npm name
yep that works, I think I got it going, thanks for the support @flyboarder I am now playing with the relative paths
Executing Process: /home/arichiardi/git/ar-website/node_modules/less/bin/lessc
Process failed with...:
FileError: 'css/semantic.less' wasn't found. Tried - /home/arichiardi/.boot/cache/tmp/home/arichiardi/git/ar-website/fb4/fwjp2k/css/css/semantic.less,/home/arichiardi/.boot/cache/tmp/home/arichiardi/git/ar-website/fb4/fwjp2k/css/css/semantic.less,css/semantic.less in /home/arichiardi/.boot/cache/tmp/home/arichiardi/git/ar-website/fb4/fwjp2k/css/blog.main.less on line 1, column 1:
1 @import "css/semantic.less";
2
Process completed successfully...
it will work at the end of today 💪
awesome!