mirror of
https://github.com/penpot/penpot.git
synced 2025-01-25 07:58:49 -05:00
Merge pull request #134 from uxbox/other/dynamic-config
🎉 Make the build to be config independent.
This commit is contained in:
commit
4ee138f71e
6 changed files with 38 additions and 21 deletions
|
@ -100,6 +100,16 @@ function readLocales() {
|
|||
return JSON.stringify(result);
|
||||
}
|
||||
|
||||
function readConfig() {
|
||||
const apiUrl = process.env.UXBOX_API_URL;
|
||||
const demoWarn = process.env.UXBOX_DEMO_WARNING;
|
||||
|
||||
return JSON.stringify({
|
||||
apiUrl: (apiUrl === undefined ? "http://localhost:6060" : apiUrl.trim()),
|
||||
demoWarning: demoWarn === "true",
|
||||
});
|
||||
}
|
||||
|
||||
function templatePipeline(options) {
|
||||
return function() {
|
||||
const input = options.input;
|
||||
|
@ -108,11 +118,13 @@ function templatePipeline(options) {
|
|||
|
||||
const locales = readLocales();
|
||||
const icons = readSvgSprite();
|
||||
const config = readConfig();
|
||||
|
||||
const tmpl = mustache({
|
||||
ts: ts,
|
||||
ic: icons,
|
||||
tr: JSON.stringify(locales),
|
||||
config: JSON.stringify(config),
|
||||
translations: JSON.stringify(locales),
|
||||
});
|
||||
|
||||
return gulp.src(input)
|
||||
|
|
|
@ -14,8 +14,12 @@
|
|||
<section id="loader"></section>
|
||||
<section id="modal"></section>
|
||||
|
||||
<script>
|
||||
window.uxboxConfig = JSON.parse({{& config }});
|
||||
window.uxboxTranslations = JSON.parse({{& translations }});
|
||||
</script>
|
||||
<script src="js/cljs_base.js?ts={{& ts}}"></script>
|
||||
<script src="js/main.js?ts={{& ts}}"></script>
|
||||
<script>uxbox.main.init({{& tr }})</script>
|
||||
<script>uxbox.main.init()</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -2,10 +2,15 @@
|
|||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; Copyright (c) 2016 Andrey Antukh <niwi@niwi.nz>
|
||||
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
;; defined by the Mozilla Public License, v. 2.0.
|
||||
;;
|
||||
;; Copyright (c) 2016-2020 Andrey Antukh <niwi@niwi.nz>
|
||||
|
||||
(ns uxbox.config)
|
||||
(ns uxbox.config
|
||||
(:require [goog.object :as gobj]))
|
||||
|
||||
(goog-define url "")
|
||||
(goog-define demo-warning false)
|
||||
(goog-define default-language "en")
|
||||
(let [config (gobj/get goog.global "uxboxConfig")]
|
||||
(def default-language "en")
|
||||
(def url (gobj/get config "apiUrl" "http://localhost:6060/"))
|
||||
(def demo-warning (gobj/get config "demoWarning" true)))
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
(:require
|
||||
[cljs.spec.alpha :as s]
|
||||
[beicon.core :as rx]
|
||||
[goog.object :as gobj]
|
||||
[rumext.alpha :as mf]
|
||||
[uxbox.main.data.auth :refer [logout]]
|
||||
[uxbox.main.data.users :as udu]
|
||||
|
@ -66,11 +67,12 @@
|
|||
(def app-sym (.for js/Symbol "uxbox.app"))
|
||||
|
||||
(defn ^:export init
|
||||
[translations]
|
||||
(i18n/init! (js/JSON.parse translations))
|
||||
(unchecked-set js/window app-sym "main")
|
||||
(st/init)
|
||||
(init-ui))
|
||||
[]
|
||||
(let [translations (gobj/get goog.global "uxboxTranslations")]
|
||||
(i18n/init! translations)
|
||||
(unchecked-set js/window app-sym "main")
|
||||
(st/init)
|
||||
(init-ui)))
|
||||
|
||||
(defn reinit
|
||||
[]
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
;; defined by the Mozilla Public License, v. 2.0.
|
||||
;;
|
||||
;; Copyright (c) 2015-2019 Andrey Antukh <niwi@niwi.nz>
|
||||
|
||||
(ns uxbox.main.data.workspace
|
||||
|
|
|
@ -28,20 +28,11 @@
|
|||
|
||||
;; --- Generic Build Options
|
||||
|
||||
(def closure-defines
|
||||
(let [url (some-> (:uxbox-api-url env)
|
||||
(str/trim))
|
||||
demo-warn (some-> (:uxbox-demo-warning env)
|
||||
(str/trim))]
|
||||
{'uxbox.config.url (if (nil? url) "http://localhost:6060" url)
|
||||
'uxbox.config.demo-warning (= "true" demo-warn)}))
|
||||
|
||||
(def default-build-options
|
||||
{:cache-analysis true
|
||||
:parallel-build true
|
||||
:language-in :ecmascript6
|
||||
:language-out :ecmascript5
|
||||
:closure-defines closure-defines
|
||||
:anon-fn-naming-policy :mapped
|
||||
:optimizations :none
|
||||
:infer-externs true
|
||||
|
|
Loading…
Add table
Reference in a new issue