Skip to content

Commit

Permalink
wegue-oss#98 app-specific config file location under app/
Browse files Browse the repository at this point in the history
  • Loading branch information
justb4 committed May 24, 2020
1 parent bfc36d9 commit f8e8e02
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,27 @@ if (appCtx) {
appCtxFile = '-' + appCtx.replace(/(\.\.[/])+/g, '');
}

fetch('static/app-conf' + appCtxFile + '.json')
const createApp = function (appConfig) {
// make app config accessible for all components
Vue.prototype.$appConfig = appConfig;
/* eslint-disable no-new */
new Vue({
el: '#app',
template: '<wgu-app/>',
components: { WguApp }
});
};

// First look in the app dir for an app-specific config file.
fetch('app/static/app-conf' + appCtxFile + '.json')
.then(function (response) {
return response.json();
})
.then(function (appConfig) {
// make app config accessible for all components
Vue.prototype.$appConfig = appConfig;
/* eslint-disable no-new */
new Vue({
el: '#app',
template: '<wgu-app/>',
components: { WguApp }
});
return response.json().then(function (appConfig) {
createApp(appConfig);
})
}).catch(function () {
fetch('static/app-conf' + appCtxFile + '.json').then(function (response) {
return response.json().then(function (appConfig) {
createApp(appConfig);
})
})
});

0 comments on commit f8e8e02

Please sign in to comment.