簡體   English   中英

Clojure中的cljsbuild加載緩慢

[英]Slow loading of cljsbuild in Clojure

我是Clojure的新手,我正在嘗試建立一個開發環境,在這里我可以使用ring-server和cljsbuild動態加載Web項目文件

我的項目文件中包含以下代碼段

:ring {
      :handler cjohansen-no.web/app
      ;;:auto-refresh true
      ;;:auto-reload? true
      ;;:reload-paths ["resources","src"]
      ;;:refresh-paths ["resources","src"]
    }
  :aliases {
        "start-server" ["ring" "server-headless"]
        "build-site" ["run" "-m" "cjohansen-no.web/export"]
        "build-html" ["run" "-m" "cjohansen-no.web/export-pages"]
        "build-js" ["cljsbuild" "auto" "dev"]
        "build-web" ["do" ["build-site"] ["build-js"]]
        "build-dev" ["pdo" ["build-web"] ["start-server"] ["auto" "build-html"]]
            }
  :source-paths ["src"]
  :test-paths ["test/cjohansen_no" "test/cljs" "spec"]
  :clean-targets [:target-path "./build/js/out"
                  :compile-path "classes"
                  :output-paths "./build/js/output"
                  "build/js/main.js.map"
                  ]
  :main cjohansen-no.web
  :clean-non-project-classes true
  :figwheel {
    ;;:server-port 3000
    :css-dirs ["resources/public/css"]
    :reload-clj-files {:clj true :cljc false}
    :ring-handler cjohansen-no.web/app
    :repl false
  }
  :cljsbuild {
    :builds [

      {
      ;; :notify-command ["growlnotify" "-m"]
      :id "dev"
      :source-paths ["src/cljs"]
      :figwheel {
          :websocket-host :js-client-host
          :autoload false
          :reload-dependents true
          :debug true
      }
      :compiler {
             :main scripts.core
             :output-to "resources/public/js/main.js"
             :output-dir "resources/public/js/out"
             :optimizations :none
             :source-map true
             :source-map-timestamp true
             :recompile-dependents false
             :pretty-print true
             :asset-path "js/out"

             ;;:notify-command ["bin/phantomjs"  "bin/speclj.js" "resources/public/js/main.js"]
           }

      }, 
....
}
  :profiles {
            :dev {
                :dependencies [
                  ;;[figwheel "0.5.4-7"]
                ]
                :plugins [
                    [lein-pdo "0.1.1"]
                    [lein-ring "0.9.7"]
                    [lein-cljsbuild "1.1.3"]
                    [lein-figwheel "0.5.4-7"]
                  ]
             }

我使用此代碼段運行服務器

(def app (->
            (stasis/serve-pages get-pages)
            (optimus/wrap get-assets optimizations/all serve-live-assets)
            ;;(wrap-cljsbuild "/js/" cljsbuild)
             wrap-content-type
             ;; wrap-reload
             wrap-utf-8))

我正在使用擎天柱加載資產

(defn get-assets []
  (concat (assets/load-bundle "public" "styles.css" [#"css/.+\.css$"])
    (assets/load-assets "public" [#"img/.*" "/questions.json"])
    (assets/load-bundle "public" "main.js" [#"js/.+\.js"])
    ))

當我運行lein with-profile dev pdf start-server, cljsbuild auto打開我的網站,而“ dev”版本編譯的js文件及其依賴項將永遠需要完成加載。 為什么環形服務器這么慢?

我應該以這種方式引用構建文件嗎? 我應該將其捆綁到一個文件中嗎?

所使用的配置文件用於開發目的。

如果您剛剛起步並且對clojure / clojurescript不熟悉,那將是一個非常復雜的project.clj文件。 可能僅以光禿禿的lein figwheel模板開始可能是獲得基本環境的好方法,然后在您知道需要更多位后再添加它。 可能僅僅是解析項目文件會減慢速度。

基本的Figwheel模板將進行設置,以便在必要時全部重新加載-實際上,您無需擔心太多額外的事情。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM