From 723a19cd8b6f6dca517bccdcfd959dff90495fab Mon Sep 17 00:00:00 2001 From: vitorsemeano Date: Sun, 18 Oct 2020 22:31:46 +0100 Subject: [PATCH] removed import for config.json for fetch --- src/scripts/settings/webSettings.js | 21 +++++++++++++++++---- webpack.common.js | 4 ++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/scripts/settings/webSettings.js b/src/scripts/settings/webSettings.js index f8385ae920..1304b83b9a 100644 --- a/src/scripts/settings/webSettings.js +++ b/src/scripts/settings/webSettings.js @@ -43,9 +43,16 @@ async function fetchLocal(url, options) { async function getConfig() { if (data) return Promise.resolve(data); try { - data = (await import('../../config.json')).default; + const response = await fetchLocal('config.json', { + cache: 'no-cache' + }); + + if (!response.ok) { + throw new Error('network response was not ok'); + } + + data = await response.json(); - console.dir(data); return data; } catch (error) { console.warn('failed to fetch the web config file:', error); @@ -55,9 +62,15 @@ async function getConfig() { async function getDefaultConfig() { try { - data = (await import('../../config.template.json')).default; + const response = await fetchLocal('config.template.json', { + cache: 'no-cache' + }); - console.dir(data); + if (!response.ok) { + throw new Error('network response was not ok'); + } + + data = await response.json(); return data; } catch (error) { console.error('failed to fetch the default web config file:', error); diff --git a/webpack.common.js b/webpack.common.js index 61efd4c5a5..4a401501e0 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -15,6 +15,10 @@ module.exports = { new CleanWebpackPlugin(), new CopyPlugin({ patterns: [ + { + from: 'config*.json', + to: '' + }, { from: 'themes/', to: 'themes/'