feat: add worker build to figwheel

This commit is contained in:
Andrey Antukh 2019-06-03 17:21:07 +02:00
parent a2c41cf9a7
commit 7adc4e3d01
2 changed files with 20 additions and 14 deletions

View file

@ -16,7 +16,7 @@
"dist:worker": "clojure -Adev tools.clj dist worker", "dist:worker": "clojure -Adev tools.clj dist worker",
"dist:assets": "gulp dist", "dist:assets": "gulp dist",
"prod": "gulp dist --production", "prod": "gulp dist --production",
"start": "npm run build:worker && npm run figwheel", "start": "npm run figwheel",
"build:worker": "clojure -Adev tools.clj build worker", "build:worker": "clojure -Adev tools.clj build worker",
"figwheel": "clojure -Adev tools.clj figwheel" "figwheel": "clojure -Adev tools.clj figwheel"
}, },

View file

@ -21,8 +21,8 @@
"uxbox.config.isdemo" demo?}) "uxbox.config.isdemo" demo?})
(def default-build-options (def default-build-options
{:cache-analysis false {:cache-analysis true
:parallel-build false :parallel-build true
:language-in :ecmascript6 :language-in :ecmascript6
:language-out :ecmascript5 :language-out :ecmascript5
:closure-defines closure-defines :closure-defines closure-defines
@ -35,19 +35,20 @@
(defn get-output-options (defn get-output-options
[name dist? map?] [name dist? map?]
(let [prefix (if dist? "dist/js" "resources/public/js") (let [prefix (if dist? "dist/js" "resources/public/js")
opts {:main (symbol (str "uxbox." name)) srcmap (if (= map? ::path)
(str prefix "/" name ".js.map")
map?)]
{:main (symbol (str "uxbox." name))
:output-to (str prefix "/" name ".js") :output-to (str prefix "/" name ".js")
:output-dir (str prefix "/" name) :output-dir (str prefix "/" name)
:source-map (str prefix "/" name ".js.map") :source-map srcmap
:asset-path (str "js/" name)}] :asset-path (str "/js/" name)}))
(cond-> opts
dist? (dissoc opts :source-map))))
(defmethod task "dist" (defmethod task "dist"
[[_ name]] [[_ name]]
(api/build (api/inputs "src" "test") (api/build (api/inputs "src" "test")
(merge default-build-options (merge default-build-options
(get-output-options name true true) (get-output-options name true ::path)
{:optimizations :advanced {:optimizations :advanced
:static-fns true :static-fns true
:elide-asserts true}))) :elide-asserts true})))
@ -56,7 +57,7 @@
[[_ name]] [[_ name]]
(api/build (api/inputs "src" "test") (api/build (api/inputs "src" "test")
(merge default-build-options (merge default-build-options
(get-output-options name false true) (get-output-options name false ::path)
{:optimizations :simple}))) {:optimizations :simple})))
(defmethod task "figwheel" (defmethod task "figwheel"
@ -66,13 +67,18 @@
:auto-testing false :auto-testing false
:css-dirs ["resources/public/css" :css-dirs ["resources/public/css"
"resources/public/view/css"] "resources/public/view/css"]
:ring-server-options {:port 3449 :host "0.0.0.0"}
:watch-dirs ["src" "test"]} :watch-dirs ["src" "test"]}
{:id "main" {:id "main"
:options (merge default-build-options :options (merge default-build-options
(get-output-options "main" false false))} (get-output-options "main" false true))}
{:id "view" {:id "view"
:options (merge default-build-options :options (merge default-build-options
(get-output-options "view" false false))})) (get-output-options "view" false true))}
{:id "worker"
:options (merge default-build-options
{:target :webworker}
(get-output-options "worker" false true))}))
;;; Build script entrypoint. This should be the last expression. ;;; Build script entrypoint. This should be the last expression.