🎉 Make the build to be config independent.

Loading the configuration dinamically using
global variables defined in index.html.
This commit is contained in:
Andrey Antukh 2020-03-11 09:20:12 +01:00
parent 1ce46a0ef8
commit c09f281f58
6 changed files with 38 additions and 21 deletions

View file

@ -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)