mirror of
https://github.com/penpot/penpot.git
synced 2025-05-12 22:06:37 +02:00
🎉 Make the build to be config independent.
Loading the configuration dinamically using global variables defined in index.html.
This commit is contained in:
parent
1ce46a0ef8
commit
c09f281f58
6 changed files with 38 additions and 21 deletions
|
@ -100,6 +100,16 @@ function readLocales() {
|
||||||
return JSON.stringify(result);
|
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) {
|
function templatePipeline(options) {
|
||||||
return function() {
|
return function() {
|
||||||
const input = options.input;
|
const input = options.input;
|
||||||
|
@ -108,11 +118,13 @@ function templatePipeline(options) {
|
||||||
|
|
||||||
const locales = readLocales();
|
const locales = readLocales();
|
||||||
const icons = readSvgSprite();
|
const icons = readSvgSprite();
|
||||||
|
const config = readConfig();
|
||||||
|
|
||||||
const tmpl = mustache({
|
const tmpl = mustache({
|
||||||
ts: ts,
|
ts: ts,
|
||||||
ic: icons,
|
ic: icons,
|
||||||
tr: JSON.stringify(locales),
|
config: JSON.stringify(config),
|
||||||
|
translations: JSON.stringify(locales),
|
||||||
});
|
});
|
||||||
|
|
||||||
return gulp.src(input)
|
return gulp.src(input)
|
||||||
|
|
|
@ -14,8 +14,12 @@
|
||||||
<section id="loader"></section>
|
<section id="loader"></section>
|
||||||
<section id="modal"></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/cljs_base.js?ts={{& ts}}"></script>
|
||||||
<script src="js/main.js?ts={{& ts}}"></script>
|
<script src="js/main.js?ts={{& ts}}"></script>
|
||||||
<script>uxbox.main.init({{& tr }})</script>
|
<script>uxbox.main.init()</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -2,10 +2,15 @@
|
||||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
;; 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/.
|
;; 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 "")
|
(let [config (gobj/get goog.global "uxboxConfig")]
|
||||||
(goog-define demo-warning false)
|
(def default-language "en")
|
||||||
(goog-define 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
|
(:require
|
||||||
[cljs.spec.alpha :as s]
|
[cljs.spec.alpha :as s]
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
|
[goog.object :as gobj]
|
||||||
[rumext.alpha :as mf]
|
[rumext.alpha :as mf]
|
||||||
[uxbox.main.data.auth :refer [logout]]
|
[uxbox.main.data.auth :refer [logout]]
|
||||||
[uxbox.main.data.users :as udu]
|
[uxbox.main.data.users :as udu]
|
||||||
|
@ -66,11 +67,12 @@
|
||||||
(def app-sym (.for js/Symbol "uxbox.app"))
|
(def app-sym (.for js/Symbol "uxbox.app"))
|
||||||
|
|
||||||
(defn ^:export init
|
(defn ^:export init
|
||||||
[translations]
|
[]
|
||||||
(i18n/init! (js/JSON.parse translations))
|
(let [translations (gobj/get goog.global "uxboxTranslations")]
|
||||||
(unchecked-set js/window app-sym "main")
|
(i18n/init! translations)
|
||||||
(st/init)
|
(unchecked-set js/window app-sym "main")
|
||||||
(init-ui))
|
(st/init)
|
||||||
|
(init-ui)))
|
||||||
|
|
||||||
(defn reinit
|
(defn reinit
|
||||||
[]
|
[]
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
;; 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/.
|
;; 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>
|
;; Copyright (c) 2015-2019 Andrey Antukh <niwi@niwi.nz>
|
||||||
|
|
||||||
(ns uxbox.main.data.workspace
|
(ns uxbox.main.data.workspace
|
||||||
|
|
|
@ -28,20 +28,11 @@
|
||||||
|
|
||||||
;; --- Generic Build Options
|
;; --- 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
|
(def default-build-options
|
||||||
{:cache-analysis true
|
{:cache-analysis true
|
||||||
:parallel-build true
|
:parallel-build true
|
||||||
:language-in :ecmascript6
|
:language-in :ecmascript6
|
||||||
:language-out :ecmascript5
|
:language-out :ecmascript5
|
||||||
:closure-defines closure-defines
|
|
||||||
:anon-fn-naming-policy :mapped
|
:anon-fn-naming-policy :mapped
|
||||||
:optimizations :none
|
:optimizations :none
|
||||||
:infer-externs true
|
:infer-externs true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue