使用boot-cljs生成生产版本

时间:2019-06-10 14:38:01

标签: clojure clojurescript

我有一个clj / cljs应用程序,并且正在使用boot作为构建工具。

我有一个dev任务,可以立即给我反馈开发环境,并且效果很好!

但是,我在尝试建立一个生成.jar并可以部署到生产环境的构建任务时遇到了麻烦。

问题是:

  1. 生产版本仍尝试连接到weasel。在浏览器控制台中看到:

     websocket.js:283 WebSocket connection to 'ws://localhost:35243/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
    
  2. React Developer Tool(浏览器扩展)说,该应用程序正在使用试剂的开发版本,并指向以下URL:https://reactjs.org/docs/optimizing-performance.html#use-the-production-build。 (我已将cljs编译器优化设置为:advanced

有人可以指出我做错了什么吗?

我的dev任务如下:

(deftask add-cljs-dev-deps []
  (merge-env! :dependencies
              '[[cider/piggieback "0.4.1" :scope "test"]
                [nrepl "0.6.0" :scope "test"]
                ;; [com.cemerick/piggieback "0.2.2" :scope "test"]
                [weasel "0.7.0" :scope "test"]
                [org.clojure/tools.nrepl "0.2.13" :scope "test"]])
  identity)

(deftask dev
  "Launch Immediate Feedback Development Environment"
  []
  (require '[adzerk.boot-reload]
           '[pandeiro.boot-http]
           '[adzerk.boot-cljs-repl])
  (let [reload (resolve 'adzerk.boot-reload/reload)
        serve (resolve 'pandeiro.boot-http/serve)
        cljs-repl (resolve 'adzerk.boot-cljs-repl/cljs-repl)
        start-repl (resolve 'adzerk.boot-cljs-repl/start-repl)]
    (comp
     (add-cljs-dev-deps)
     (serve :handler 'myapp.core/app ;; ring handler
            :resource-root "public"  ;; root classpath
            :port 3500
            :reload true)            ;; reload ns
     (watch)
     (reload)
     (cljs-repl) ;; before cljs task
     (cljs :source-map true :optimizations :none)
     (sass)
     (target :dir #{"public"}))))

和我的build生产任务如下:

(deftask build
  "Builds an uberjar of this project that can be run with java -jar"
  []
  (comp
   (aot :all true) 
   (pom)
   (cljs :optimizations :advanced
         :compiler-options {:optimizations :advanced})
   (sass)
   (sift :move {#"(.*)js$" "public/$1js"
                #"(.*)html$" "public/$1html"
                #"css/(.*)" "public/css/$1"})
   (uber :exclude-scope #{"test"})
   (jar :file "myapp.jar" :main 'myapp.server )
   (sift :include #{#"myapp.jar"})
   (target)))

完整的build.boot可以在here中找到。

0 个答案:

没有答案