This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-04-13
Channels
- # announcements (1)
- # bangalore-clj (1)
- # beginners (47)
- # boot (16)
- # calva (33)
- # cider (14)
- # clj-kondo (3)
- # clojure (46)
- # clojure-india (1)
- # clojure-italy (6)
- # clojure-nl (4)
- # clojure-uk (5)
- # clojurescript (10)
- # dirac (8)
- # emacs (1)
- # fulcro (1)
- # leiningen (14)
- # lumo (1)
- # off-topic (178)
- # pathom (9)
- # planck (17)
- # quil (2)
- # reagent (5)
- # reitit (6)
- # shadow-cljs (55)
- # tools-deps (3)
Hi there, I’m looking for a way to use shadow-cljs to recompile sass files, I’ve looked into the build hooks but not sure if that can be done. Figwheel has similar capabilities via writing a custom script, and I thought you can do it using a hook, but seems like watching the sass source folder in watch mode doesn’t invoke the compile-prepare stage with the sass files that were changed. I know you can run some other watcher, but I believe one of the goals of shadow-cljs is to reduce the number of build tools and processes running, so it’ll be nice to find a way to do that.
@talgiat there is a very basic "plugin" feature that I started working one quite a while ago. I isn't documented since I'm still not sure I want to go with that route so I wouldn't make any guarantees that it stays the way it is but you could definitely build all kinds of things with that
it works like this https://github.com/thheller/shadow-cljs/blob/master/shadow-cljs.edn#L17
:start
should be a function. :stop
should be a function that will be called with whatever :start
returned when the server shuts down
so for example you could start a sass process in :start
, return the process handle and kill it in :stop
:build-hooks
are indeed not a good fit for something like sass since sass compilation is independent of CLJS
@talgiat I’ve done this by wrapping kickstarting the shadow CLJS build processes from my own code. I could share something come Monday.
there is also stuff like run-p
from npm. https://github.com/mysticatea/npm-run-all/blob/HEAD/docs/run-p.md
thanks @thheller is there an option to watch some folder with shadow (same way that the build works), so I can watch the sass folder and run sassc command on file chagnes? I saw watch under worker.clj but not sure if that’s something too internal to use. @orestis a code sample would be great
@talgiat I basically just use the hawk library (shadow already depends on it) to run sass-clj
(fs-watch/start
{}
[(io/file "some" "dir")]
["scss"]
(fn [updates]
(prn [:scss-updates updates])
))
How do I get a CLJS repl using node-test
target? When I try to connect to a REPL, I'm getting "No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code."
that is not supported. tests are supposed to run once and exit (since we need the exit code)
Oh, I think the documentation must be outdated: it say "The node process exit code will not be returned when using :autorun
", so I though I could use it to run a REPL
:autorun
executes the tests the a watch
build completes. the node
process running the tests will still exit. the shadow-cljs
process however continues.
What's the preferred way to develop code targeting Node.JS? Right now I'm using two targets, one to autorun tests and one to compile the project. Is there another way you recommend?
docs could probably explain that in more detail but the work the node process does remains the same
that is up to you. I tend to do it the same way I do CLJ development ... using the REPL
:node-script
targets I usually run with :devtools {:enabled false}
since I want them to exit when they "complete"
Yes, I do use the same way, but in Clojure mode I require a test namespace even when none of my "main" namespace doesn't require it. On CLJS, this is not really possible, so that's why I'm using another target
For example, when I use :node-script
I need a :main
function - my tests namespaces are not included on the :main
namespace
So when I save a test file, it doesn't get compiled...
and in Clojure mode I can force a "require" and run it by the REPL
I think I missed the documentation part about :preloads
. Great to know! I'll check it. Thanks 🙂
I'll check out and post if it works for me. Thanks again 🙂
@mauricio.szabo what stops you from running (require 'your.test-ns)
at the REPL?
In my experience this tends to confuse reloads. Maybe newer versions have fixed this issue though... I'll probably need to revisit my workflow :)