Skip to content

Setup my System environment need some advice. #123

@idhowardgj94

Description

@idhowardgj94

hello, I'm a newbie in clojure & clojureScript,

just try to learn and have fun with this amazing language.

currently, I faced a problem,

I try to use rum + tailwindcss + postcss + shadow-cljs + lein to setup my entire frontend application.

And I use lein run to run clojure code, which will start postcss and shadow-cljs dev server as an agent.

(ns dev.main
  (:require [clojure.java.shell :as shell]
            [shadow.cljs.devtools.api :as api]
            [shadow.cljs.devtools.server :as server]))

(defn watch-css
  ;; build and watch css.
  []
  (future (apply shell/sh ["node_modules/.bin/postcss" "--watch" "src/resume/assets/main.css"
                           "-o" "public/main.css"
                           "--config" "src/config/postcss.config.js"]))
    (println "[INFO] watch css......"))

(watch-css)
(defn start-server!
  []
  (server/start!))

(defn start-watch!
  []
  (api/watch :app))

(defn stop-watch!
  []
  (server/stop!))

(defn -main
  []
  (println "running postcss command...")
  (watch-css)


  (println "Start shadow-cljs develop server...")
  (start-server!)
  (start-watch!)
  (.addShutdownHook (Runtime/getRuntime) (Thread. #(do
                                                     (println "stop server...")
                                                     (stop-watch!)
                                                     (println "bye.")))))

The problem is that, postcss won't recompile if my cljs file changed.

if I use --watch in (watch-css)'s shell command,

this shell was just instantly stop, and noting return, and no css build.

currently, I use lein alias + pdo workaround to solve this problem.

  :plugins [[lein-shell "0.5.0"]
            [lein-pdo "0.1.1"]]
 :aliases {"shadow-cljs-run" ["run" "-m" "shadow.cljs.devtools.cli"]
            "dev" ["run" "-m" "shadow.cljs.devtools.cli" "watch" "app"]
            "css" ["shell"
                   "node_modules/.bin/postcss" "src/resume/assets/main.css"
                   "-o" "public/main.css"
                   "-w"
                   "--config" "src/config/postcss.config.js"]}

and use command to start clojure system:

lein pdo css, run

and it worked. but I wonder is this a problem that mount can solve?

if it is, how can I achieve my goal?

thanks for help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions