removed import for config.json for fetch

This commit is contained in:
vitorsemeano 2020-10-18 22:31:46 +01:00
parent 9030aa2817
commit 723a19cd8b
2 changed files with 21 additions and 4 deletions

View file

@ -43,9 +43,16 @@ async function fetchLocal(url, options) {
async function getConfig() { async function getConfig() {
if (data) return Promise.resolve(data); if (data) return Promise.resolve(data);
try { 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; return data;
} catch (error) { } catch (error) {
console.warn('failed to fetch the web config file:', error); console.warn('failed to fetch the web config file:', error);
@ -55,9 +62,15 @@ async function getConfig() {
async function getDefaultConfig() { async function getDefaultConfig() {
try { 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; return data;
} catch (error) { } catch (error) {
console.error('failed to fetch the default web config file:', error); console.error('failed to fetch the default web config file:', error);

View file

@ -15,6 +15,10 @@ module.exports = {
new CleanWebpackPlugin(), new CleanWebpackPlugin(),
new CopyPlugin({ new CopyPlugin({
patterns: [ patterns: [
{
from: 'config*.json',
to: ''
},
{ {
from: 'themes/', from: 'themes/',
to: 'themes/' to: 'themes/'